vue.set( target, key, value ) this.$set(对象获数组,要更改的具体数据,重新赋值)用法

调用方法:Vue.set( target, key, value )

target:要更改的数据源(可以是对象或者数组)

key:要更改的具体数据

value :重新赋的值

具体用法
js代码:
//设置初始状态和值
let j = { id: 0, "progressTime": "", "progressContent": "", "isSet": true, "_temporary": true };
_this.tableInFormData = []
//将对象加入到数组 
this.tableInFormData.push(j);
//项目将isSet变为true 从而v-if来判断输入框可以使用
_this.$set(_this.tableInFormData[index],"isSet",true)        

下面放html代码:

          <el-table-column label="时间"
                                 width="300"
                                 :show-overflow-tooltip="true">
                    <template slot-scope="scope" >
                         <span v-if="scope.row.isSet">
                             <el-date-picker
                                     v-model="form2.progressTime"
                                     type="datetime"
                                     :picker-options="pickerBeginDateBefore"
                                     format="yyyy-MM-dd HH:mm:ss"
                                     value-format="yyyy-MM-dd HH:mm:ss"
                                     placeholder="选择日期">
                                     <!--:disabled="true">-->
                              </el-date-picker>
                          </span>
                        <span v-else>{{changeTimeToDate(scope.row.ProgressTime) }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="ProgressContent"
                                 label="处置进展"
                                 :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                         <span v-if="scope.row.isSet">
                             <el-input size="small" v-model="form2.progressContent" placeholder="请输入内容" ></el-input>
                         </span>
                        <span v-else>{{(scope.row.ProgressContent) }}</span>
                    </template>
                </el-table-column>

猜你喜欢

转载自www.cnblogs.com/fallIntoTheStars/p/11983461.html
今日推荐