zoukankan      html  css  js  c++  java
  • elementUI动态添加

    elementUI动态添加

     添加描述:

    <el-form-item 
      v
    -for="(item, index) in ruleForm.domains" domaina是存放绑定值的数组
      
    :key="item.key"
      :prop="'domains.' + index + '.textareb'" textareb是输入框绑定的值
      :rules="{
      required: true,
      message: '请填写课程介绍',
      trigger: 'blur'}
    "

    > <el-input type="textarea" v-model="item.textareb" maxlength="300"style="524px;margin-left:16px" resize="none" class="aaaaaaaaaaaaa"> </el-input> <el-button type="primary" icon="el-icon-delete" class="addBtn" @click.prevent="inputRemove(item)"> item这个参数就是绑定的值
        <i>删除</i>
    </el-button> </el-form-item>

    data中:
      domains: [
              {
                textareb: ""
              }
            ]
     
    事件用到push:
    // 添加备注按钮
        addDesc() {
          // alert(111);
          this.ruleForm.domains.push({
            textareb: "",
            key: Date.now()
          });
        }
       
    inputRemove(item) {
          // alert(item);
          var index = this.ruleForm.domains.indexOf(item);
          if (index !== -1) {
            this.ruleForm.domains.splice(index, 1);
          }
        }

    DIV

    <div class="textarebDiv" v-for="(v, i) in list">
                        <el-button
                          type="primary"
                          icon="el-icon-delete"
                          class="addBtn aadaadBtn"
                          @click.prevent="divRemove(i)"
                          style="background:none"
                          ><i>删除</i></el-button
                        >
    </div>

    data中:
     list: [{ contactType: "", number: "" }]
     
    事件
    addImg() {
          this.list.push({ contactType: "", number: "" });
        },
    // div中的删除事件‘
        divRemove(i) {
          this.list.splice(i, 1);
        }
  • 相关阅读:
    local 不能解析为127.0.0.1
    完全使用接口方式调用WCF 服务
    【人生】自己对于求职应聘的一些感受
    OO的经典例子
    剪刀、石头、布机器人比赛
    TextTree 文本资料收集轻量级工具
    两个代替重复输入的小工具
    桌面助手 Desktop Helper 自动帮你关闭指定的窗口
    磁盘可用空间平衡
    用C#制造可以继承的“枚举”
  • 原文地址:https://www.cnblogs.com/home-/p/11704698.html
Copyright © 2011-2022 走看看