iview table展開項的使用

父組件table的數據

columns: [
        {
          type: 'expand',
          width: 50,
          render: (h, params) => {
            this.expandList = params.row.children ? params.row.children : []
            return h(expandRow, {
              props: {
                row: this.expandList,
                departid: params.row.id,
                departname: params.row.name,
                departIndex: params.index
              },
              on: {
                'fatherMethod': (val) => {     //當子組件數據變動時,調用父組件的函數getData
                  this.getData(val)
                }
              }
            })
          }
        }]

子組件

handleSubmit () {
      var data = {}
      SetGepart(data).then(res => {
        if (res.data.errno == 0) {
          this.$emit('fatherMethod', this.departIndex) //調用父組件的函數
          this.$Message.success('編輯成功')
        } else {
          this.$Message.error(res.data.message)
        }
      }).catch(err => {
        console.log(err)
      })
    },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章