当碰到作品或者商品上下架并且禁用一些按钮时
首先按后端获取的数值修改文字效果
{{scope.row.publishState === 0 ? '下架' : '上架'}}
当上架之后禁用某个功能添加一下功能
//scope.row.publishState是后端获取的数据
:disabled="scope.row.publishState === 1 ? false : true"
需求:
效果:
代码:
// 点击下架
soldout (row) {
this.okgrounding({ id: row.id, publishState: row.publishState === 0 ? 1 : 0 })
this.highlowlimit = true
console.log(row)
this.acquestions()
},
// 点击确定更改上下架
okgrounding (row) {
this.$confirm('您确认上架这道题目吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
//使用api
const res = await choicePublish(row)
// this.highlowlimit = false
console.log(row)
console.log('点击下架', res)
this.$message({
type: 'success',
message: '操作成功!'
})