欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2018年11月02日 09:29:35   作者:玩大神的SF  
這篇文章主要介紹了解決iview多表頭動(dòng)態(tài)更改列元素發(fā)生的錯(cuò)誤的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

解決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>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue項(xiàng)目創(chuàng)建并引入餓了么elementUI組件的步驟

    vue項(xiàng)目創(chuàng)建并引入餓了么elementUI組件的步驟

    這篇文章主要介紹了vue項(xiàng)目創(chuàng)建并引入餓了么elementUI組件的步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-04-04
  • vue中g(shù)et和post請(qǐng)求的區(qū)別點(diǎn)總結(jié)

    vue中g(shù)et和post請(qǐng)求的區(qū)別點(diǎn)總結(jié)

    在本篇文章里小編給大家分享的是一篇關(guān)于vue中g(shù)et和post請(qǐng)求的區(qū)別點(diǎn)總結(jié)內(nèi)容,對(duì)此有興趣的朋友們可以跟著學(xué)習(xí)下。
    2021-12-12
  • Vue js如何用split切分并去掉空值和item的空格

    Vue js如何用split切分并去掉空值和item的空格

    這篇文章主要介紹了Vue js如何用split切分并去掉空值和item的空格,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • vue開發(fā)移動(dòng)端底部導(dǎo)航條功能

    vue開發(fā)移動(dòng)端底部導(dǎo)航條功能

    這篇文章主要介紹了vue開發(fā)移動(dòng)端底部導(dǎo)航條功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-04-04
  • vue.js指令v-for使用以及下標(biāo)索引的獲取

    vue.js指令v-for使用以及下標(biāo)索引的獲取

    今天小編就為大家分享一篇關(guān)于vue.js指令v-for使用以及下標(biāo)索引的獲取,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • Vue2.x通用編輯組件的封裝及應(yīng)用詳解

    Vue2.x通用編輯組件的封裝及應(yīng)用詳解

    這篇文章主要為大家詳細(xì)介紹了Vue2.x通用編輯組件的封裝及應(yīng)用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-05-05
  • Vue.extend 登錄注冊(cè)模態(tài)框的實(shí)現(xiàn)

    Vue.extend 登錄注冊(cè)模態(tài)框的實(shí)現(xiàn)

    這篇文章主要介紹了Vue.extend 登錄注冊(cè)模態(tài)框的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • 從Element日期組件源碼中學(xué)到的兩個(gè)工具方法技巧

    從Element日期組件源碼中學(xué)到的兩個(gè)工具方法技巧

    這篇文章主要介紹了從Element日期組件源碼中學(xué)到的兩個(gè)工具方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-08-08
  • 10分鐘上手vue-cli 3.0 入門介紹

    10分鐘上手vue-cli 3.0 入門介紹

    這篇文章主要介紹了10分鐘上手vue-cli 3.0 入門介紹,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-04-04
  • vue3使用vue-count-to組件的實(shí)現(xiàn)

    vue3使用vue-count-to組件的實(shí)現(xiàn)

    這篇文章主要介紹了vue3使用vue-count-to組件的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12

最新評(píng)論