Vue Vue 2.0 后的组件跟元素只能一个,是否存在不影响 table 的根元素?

QueXuQ · April 27, 2017 · Last by yakjuly replied at April 27, 2017 · 7910 hits
Vue.component('type-tr', {
  template: '\
    <tr>\
      <slot name="info"></slot>\
      <td><button @click="checkNodes">按钮</button></td>\
    </tr>\
    <tr v-if="isNodes">Yes</tr>\
  ',

  data: function () {
    return {
      isNodes: false
    }
  },

  methods: {
    checkNodes: function() {
      this.isNodes = true;
    }
  }
})

我想写个类似上面的代码,就是当低级按钮时,改变 isNodes 的属性,然后显示下面的tr但是根元素不允许有两个,所以这种方法各位会怎么写?

<tbody>在外面包一层

You need to Sign in before reply, if you don't have an account, please Sign up first.