テーブルの要素UI 2.8バージョンツリー全体が起動ソリューションをデフォルトすることはできません

    <el-table
      ref="tableTreeRef"
      :data="tableDate"
      ......
    </el-table>

JS:

watch: {
    tableDate: function (nv, ov) {
      this.$nextTick(() => {
        this.unFoldAll()
      })
    }
  }
/**
     * 展开所有下级
     */
    unFoldAll () {
      let queryResult = this.$refs.tableTreeRef.$el.children[2].querySelectorAll('tr')
      for (let i = 0; i < queryResult.length; i++) {
        let item = queryResult[i]
        item.style.display = ''
        let classList = item.querySelectorAll('td > div > div')[0].classList
        classList.contains('el-table__expand-icon') && item.querySelectorAll('td > div > div')[0].classList.add('el-table__expand-icon--expanded')
      }
      // IE 不支持 forEach
      // this.$refs.tableTreeRef.$el.children[2].querySelectorAll('tr').forEach(item => {
      //   item.style.display = ''
      //   let classList = item.querySelectorAll('td > div > div')[0].classList
      //   classList.contains('el-table__expand-icon') && item.querySelectorAll('td > div > div')[0].classList.add('el-table__expand-icon--expanded')
      // })
    },
    /**
     * 收起所有下级
     */
    foldAll () {
      let queryResult = this.$refs.tableTreeRef.$el.children[2].querySelectorAll('tr')
      for (let i = 0; i < queryResult.length; i++) {
        let item = queryResult[i]
        if (i !== 0) {
          item.style.display = 'none'
        }
        let classList = item.querySelectorAll('td > div > div')[0].classList
        classList.contains('el-table__expand-icon') && item.querySelectorAll('td > div > div')[0].classList.remove('el-table__expand-icon--expanded')
      }
      // IE 不支持 forEach
      // this.$refs.tableTreeRef.$el.children[2].querySelectorAll('tr').forEach((item, index) => {
      //   if (index !== 0) {
      //     item.style.display = 'none'
      //   }
      //   let classList = item.querySelectorAll('td > div > div')[0].classList
      //   classList.contains('el-table__expand-icon') && item.querySelectorAll('td > div > div')[0].classList.remove('el-table__expand-icon--expanded')
      // })
    }

おすすめ

転載: www.cnblogs.com/520future/p/11240602.html