国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

解決iview多表頭動(dòng)態(tài)更改列元素發(fā)生的錯(cuò)誤的方法

2019-11-19 12:35:44
字體:
供稿:網(wǎng)友

解決iview 'You may have an infinite update loop in watcher with expression "columns"'

解決方案

單表頭是可以動(dòng)態(tài)變化不需要增添什么東西

多表頭目前iview尚不能動(dòng)態(tài)變化,會(huì)報(bào)錯(cuò)You may have an infinite update loop in watcher with expression "columns"解決方法是github大神提供的:需要修改iview.js源碼

將iview.js中

columns: {  handler: function handler() {    var colsWithId = this.makeColumnsId(this.columns);    his.allColumns = (0, _util.getAllColumns)(colsWithId);    this.cloneColumns = this.makeColumns(colsWithId);    this.columnRows = this.makeColumnRows(false, colsWithId);    this.leftFixedColumnRows = this.makeColumnRows('left', colsWithId);    this.rightFixedColumnRows = this.makeColumnRows('right', colsWithId);    this.rebuildData = this.makeDataWithSortAndFilter();    this.handleResize();    },   deep: true  },

修改為

columns: {   handler: function handler() {     //[Fix Bug]You may have an infinite update loop in watcher with expression "columns"     var tempClonedColumns = (0, _assist.deepCopy)(this.columns);     var colsWithId = this.makeColumnsId(tempClonedColumns);     //[Fix Bug End]     this.allColumns = (0, _util.getAllColumns)(colsWithId);     this.cloneColumns = this.makeColumns(colsWithId);     this.columnRows = this.makeColumnRows(false, colsWithId);     this.leftFixedColumnRows = this.makeColumnRows('left', colsWithId);     this.rightFixedColumnRows = this.makeColumnRows('right', colsWithId);     this.rebuildData = this.makeDataWithSortAndFilter();     this.handleResize();     },   deep: true   },

demo

<template> <div>  單表頭: <Table :columns="columns1" @on-row-click="onRowClick" :data="data1"></Table>  多表頭:  <Table :columns="columns12" @on-row-click="onRowClick2" :data="data1" border height="500"></Table> </div></template><script> export default {  data() {   return {    columns1: [     {      title: 'Name',      key: 'name'     },     {      title: 'Age',      key: 'age'     },     {      title: 'Address',      key: 'address'     }    ],    data1: [     {      name: 'John Brown',      age: 18,      address: 'New York No. 1 Lake Park',      date: '2016-10-03'     },     {      name: 'Jim Green',      age: 24,      address: 'London No. 1 Lake Park',      date: '2016-10-01'     },     {      name: 'Joe Black',      age: 30,      address: 'Sydney No. 1 Lake Park',      date: '2016-10-02'     },     {      name: 'Jon Snow',      age: 26,      address: 'Ottawa No. 2 Lake Park',      date: '2016-10-04'     }    ],    columns12: [{     title: 'Name',     align:'center',     children: [{      title: 'nickName',      key: 'name',     },      {       title: 'realName',       key: 'name'      }     ]    },     {      title: 'Age',      key: 'age'     },     {      title: 'Address',      key: 'address'     }    ],   }  },  methods: {   onRowClick() {    if('City'!==this.columns1[this.columns1.length-1].title) {     this.columns1.splice(this.columns1.length, 0, {      title: 'City',      key: 'address'     })    }   },   onRowClick2() {    if('City'!==this.columns12[this.columns12.length-1].title) {     this.columns12.splice(this.columns12.length, 0, {      title: 'City',      key: 'address'     })    }   }  }, }</script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿拉善盟| 广元市| 百色市| 漳浦县| 金湖县| 达尔| 阳春市| 淮阳县| 营山县| 景泰县| 天气| 东台市| 葵青区| 烟台市| 兴宁市| 滨州市| 密山市| SHOW| 阳东县| 桃园市| 襄城县| 石林| 祁东县| 中阳县| 缙云县| 威信县| 石棉县| 大厂| 怀仁县| 泰兴市| 黎川县| 靖江市| 镇巴县| 崇左市| 达孜县| 桦南县| 密山市| 正镶白旗| 永兴县| 牟定县| 东兴市|