葬空吟 2023-07-20 15:29 采纳率: 61%
浏览 13
已结题

ant design vue 页面不显示输入框

前端框架:ant design vue @1.6.2
在a-form中想增加一个功能,有一个输入框,输入框后面是加号按钮,点击加号按钮后会再出现一个输入框,第一个输入框后面的加号变成减号,第二个输入框后面是加号,一次类推,输入框中的值会绑定checkForm.eol_defect
现在按照下面的代码,页面不显示输入框(如下图所示)

img

。。。。前面的省略

        <a-row v-show="checkForm.preorderPoint && checkForm.preorderPoint.includes('EOL')">
          <a-col :span="8"></a-col>
          <a-col :span="10">
            <p style="font-size: 18px;font-weight: bold;"> 前序监控EOL语言描述</p>
          </a-col>
        </a-row>

        <a-form-model-item v-show="checkForm.preorderPoint && checkForm.preorderPoint.includes('EOL')" label="EOL语言描述">

          <div v-for="(item, index) in checkForm.eol_defect" :key="index">
            <a-input v-model="checkForm.eol_defect[index]" style="width: 100%;"></a-input>
            <a-button v-if="index === checkForm.eol_defect.length - 1" @click="addInput">+</a-button>
            <a-button v-else @click="removeInput(index)">-</a-button>
          </div>

        </a-form-model-item>
。。。。后面的省略

export default {
  data() {
    return {
      checkForm: {
        eol_defect:[],
        }
    }
  },


  methods: {
    addInput() {
      this.checkForm.eol_defect.push('');
    },
    removeInput(index) {
      this.checkForm.eol_defect.splice(index, 1);
    },
}
};
。。。。后面的省略
  • 写回答

1条回答 默认 最新

  • MarkHan_ 2023-07-20 15:38
    关注
    <template>
      <div>
        <!-- 根据条件显示前序监控EOL语言描述部分 -->
        <a-row v-show="checkForm.preorderPoint && checkForm.preorderPoint.includes('EOL')">
          <a-col :span="8"></a-col>
          <a-col :span="10">
            <p style="font-size: 18px;font-weight: bold;">前序监控EOL语言描述</p>
          </a-col>
        </a-row>
    
        <!-- 表单项包裹 -->
        <a-form-model-item
          v-show="checkForm.preorderPoint && checkForm.preorderPoint.includes('EOL')"
          label="EOL语言描述"
          prop="eol_defect"
        >
          <!-- 循环显示输入框和按钮 -->
          <div v-for="(item, index) in checkForm.eol_defect" :key="index">
            <!-- 输入框,双向绑定到checkForm.eol_defect数组 -->
            <a-input v-model="checkForm.eol_defect[index]" style="width: 100%;"></a-input>
            <!-- 如果是最后一个输入框,显示加号按钮 -->
            <a-button v-if="index === checkForm.eol_defect.length - 1" @click="addInput">+</a-button>
            <!-- 否则显示减号按钮 -->
            <a-button v-else @click="removeInput(index)">-</a-button>
          </div>
        </a-form-model-item>
      </div>
    </template>
    
    <script>
    export default {
      data() {
        return {
          checkForm: {
            eol_defect: [], // 修复此处的拼写错误
          },
        };
      },
    
      methods: {
        addInput() {
          this.checkForm.eol_defect.push('');
        },
        removeInput(index) {
          this.checkForm.eol_defect.splice(index, 1);
        },
      },
    };
    </script>
    
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 9月20日
  • 修改了问题 7月20日
  • 创建了问题 7月20日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表