element+vue點擊新增表格內在已有數據添加一行帶輸入框內容


在element+vue項目中,需求要表格內已有數據,點擊新增在首行添加一行帶輸入框內容

table的數據為datas=[],那么下面是一列的數據,多列可循環或復制

   <el-table-column
              prop="name"
              label="件號"
              sortable
              show-overflow-tooltip:
              true
              align="center"
              width="180"
            >
              <template slot-scope="scope">
                <template
                  v-if="scope.row.show"
                >
                  <el-form-item
                    label=" "
                    prop="name"
                  >
                    <el-input
                      v-model="ruleForm.name"
                      disabled="true"
                      size="mini"
                    >
                      <i
                        slot="suffix"
                        class="el-input__icon el-icon-search"
                        @click="Partnum"
                      />
                    </el-input>
                  </el-form-item>
                </template>
                <template v-else>
                  <span @click="partNumber(scope.$index, scope.row)">{{ scope.row.name }}</span>
                </template>
              </template>
            </el-table-column>
這思路主要是template里面還有2個template,在data數組的操作中每條加一個屬性show來控制是顯示輸入框還是里面的某個字段,
addBtn () {// 添加按鈕事件
      let data = { show: true }
      this.datasNew.unshift(data)
    },
同思路可自定義添加各種屬性給表格做相應操作。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM