element的table的scope类型如何定义?

vue3用element的table组件

<el-table-column prop="status" label="状态" align="center">
          <template #default="scope">
            <el-tag
              :type="scope.row.status ? 'success' : 'danger'"
              class="mx-1"
              effect="dark"
            >
              {{ scope.row.status ? "启用" : "禁用" }}
            </el-tag>
          </template>
        </el-table-column>

scope的类型如何定义,status万一拼错了,也发现不了,很尴尬

阅读 3.5k
2 个回答
interface Info {
    status: boolean
}

模板里面做类型断言 {{ (scope.row as Info).status }}

是这样吗

:type="scope.row && scope.row.status ? 'success' : 'danger'"
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题