<el-button type="text" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row)" v-if="scope.row.finishTime" v-hasPermi="['workflow:process:remove']" >删除</el-button>这怎么写if语句判断根据状态为0展示,为1不展示
时间: 2024-03-16 22:42:59 浏览: 22
你可以使用三元表达式来实现这个逻辑:
```
v-if="scope.row.finishTime === 0 ? true : false"
```
如果`finishTime`等于0,则条件为`true`,按钮会展示;如果`finishTime`不等于0,则条件为`false`,按钮不会展示。
相关问题
vue 怎么写个判断, <el-button type="text" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row)" v-if="scope.row.finishTime" v-hasPermi="['workflow:process:remove']" >删除</el-button> <el-button type="text" size="mini" icon="el-icon-circle-close" @click="handleStop(scope.row)" >取消</el-button>,已完成显示删除,没完成显示取消
可以使用三元表达式来判断,代码如下:
```
<el-button
type="text"
size="mini"
icon="el-icon-{{ scope.row.finishTime ? 'delete' : 'circle-close' }}"
@click="scope.row.finishTime ? handleDelete(scope.row) : handleStop(scope.row)"
v-hasPermi="['workflow:process:remove']"
>
{{ scope.row.finishTime ? '删除' : '取消' }}
</el-button>
```
通过 `scope.row.finishTime` 来判断任务是否已完成,如果已完成,则按钮显示为删除,点击按钮调用 `handleDelete` 方法;如果未完成,则按钮显示为取消,点击按钮调用 `handleStop` 方法。同时使用插值语法来动态显示按钮文字。
怎么在这个按钮上写if语句<el-button type="text" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row)" v-if="scope.row.finishTime" v-hasPermi="['workflow:process:remove']" >删除</el-button>这怎么写if语句判断根据状态为0展示,为1不展示
你可以在 `v-if` 中判断 `scope.row.finishTime` 的值是否为 0,如果为 0 则展示该按钮,否则不展示,代码如下所示:
```html
<el-button
type="text"
size="mini"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-if="scope.row.finishTime === 0"
v-hasPermi="['workflow:process:remove']"
>
删除
</el-button>
```
这样,只有当 `scope.row.finishTime` 的值为 0 时才会展示该按钮。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)