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>

 


免責聲明!

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



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