element ui 中的 table 组件条件区块为什么不显示呢?

<el-table-column label="操作">
        <template v-if="!scope.row.children" slot-scope="scope">
          <el-button
            @click="handleEdit(scope.$index, scope.row)"
          >修改</el-button>
          <el-button
            type="success"
            @click="handleDelete(scope.$index, scope.row)"
          >启用</el-button>
          <el-button
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >停用</el-button>
        </template>
        <template v-else-if="scope.row.children" slot-scope="scope">
          <el-button
            @click="handleEdit(scope.$index, scope.row)"
          >添加授权</el-button>
          <el-link type="primary">查看授权帮助</el-link>
        </template>
      </el-table-column>

这样写为什么else区块的内容不显示呢?

讨论数量: 2

如果这个条件 v-if="!scope.row.children" 为 true,就显示这个,否则就显示else那一块。

4年前 评论

谢谢回复,已经解决了,因为scope只能有一个,所以需要在外面再套一层template,把scope移到外层去。。

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!