<template slot-scope="props"> <el-tag v-if="props.row.state === 0">失败</el-tag> <el-tag type="warning" v-if="props.row.state === 4">已发货</el-tag> <el-tag type="warning" v-if="props.row.state === 3">首充</el-tag> <el-tag type="success" v-if="props.row.state === 2">激活</el-tag> <el-tag type="success" v-if="props.row.state === 1">成功</el-tag> </template>这种代码用uniapp怎么写
时间: 2023-12-19 17:05:13 浏览: 150
在uni-app中,可以使用`u-tag`组件代替`el-tag`组件,同时也需要使用`u-template`代替`el-table`组件中的`template`。以下是示例代码:
```
<template>
<u-table :data="tableData">
<u-table-column label="状态">
<u-template slot-scope="props">
<u-tag v-if="props.row.state === 0">失败</u-tag>
<u-tag type="warning" v-if="props.row.state === 4">已发货</u-tag>
<u-tag type="warning" v-if="props.row.state === 3">首充</u-tag>
<u-tag type="success" v-if="props.row.state === 2">激活</u-tag>
<u-tag type="success" v-if="props.row.state === 1">成功</u-tag>
</u-template>
</u-table-column>
</u-table>
</template>
```
注意,在`u-template`中使用`slot-scope`代替`slot`。`u-table`和`u-table-column`组件的使用方式与`el-table`和`el-table-column`组件类似,但是需要将`template`改为`u-template`。
阅读全文