該篇繼續記錄最近項目中一些疑難知識點和坑的解決辦法。vue
<router-view :key="key"></router-view>
computed: {
key() {
// 或者 :key="$route.path" 只要保證key惟一就能夠了
return this.$route.name !== undefined? this.$route.name + +new Date(): this.$route + +new Date()
}
}
複製代碼
<ul class="jcButtonUl">
<li v-for="(item,index) in hostLoginManageButton" :key="index" @click="hostAddManage(index)">
<span :class="item.icon"></span>
{{item.btnValue}}
</li>
</ul>
複製代碼
computed:{
hostLoginManageButton(){
let buttonArray=[];
this.hostManageButtonArray.forEach(function(item,index){
if(index!==2 && index!==3 && index!==5){
buttonArray.push(item);
}
});
return buttonArray;
}
}
複製代碼
解決。bash
<el-table ref="jcqtTable" v-loading="loading" :data="tableData" tooltip-effect="dark" stripe style="width: 100%" @select="handleSelect" @selection-change="handleSelect" @select-all="handleSelect">
<el-table-column type="selection" width="55"></el-table-column>
省略
</el-table>
複製代碼
computed: {
tableData() {
return this.jcqtTableCon.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)
}
}
複製代碼
watch:{
textInput:function(val){
//操做
}
}
複製代碼
若是是監聽某一對象裏的某一項值的變化該如何作呢?往下看ui
data(){
return {
obj:{
textInput:''
}
}
},
watch:{
'obj.textInput':function(val){
//操做
}
}
複製代碼
項目沒有作完目前,陸續更新中。this