VUE中按钮和vue页面的动态渲染,同时,其他按钮联动显示禁用和不禁用

           当我们有需要,例如,按钮显示上架,页面状态显示已下架,这是修改和删除按钮是可以点击状态

当我们点击上架以后,按钮会变成下架,同时页面显示已发布,这是修改按钮和删除按钮被禁用

 效果如图所示

具体代码表示

<template>
  <el-table>
   <el-table-column label="发布状态" prop="publishState">
            <template slot-scope="scope">
              {{ scope.row.publishState === 1 ? '发布' : '已下架' }}
            </template>
          </el-table-column>
   <el-table-column label="操作" width="250" fixed="right">
            <template slot-scope="scope">
              <el-button
                type="text"
                :disabled="scope.row.chkState === 1 || scope.row.chkState === 2"
                @click="hChkState(scope.row)"
                >审核</el-button
              >
              <el-button type="text" :disabled="scope.row.publishState === 1">修改</el-button>
              <el-button type="text" @click="hPublish(scope.row)">{{
                scope.row.publishState === 0 ? '上架' : '下架'
              }}</el-button>
              <el-button type="text" :disabled="scope.row.publishState === 1" @click="hDel(scope.row)">删除</el-button>
            </template>
          </el-table-column>
  </el-table>
</template>


<script>
export default{
 

// 点击上架,下架
    hPublish(row) {
      if (row.publishState === 0) {
        this.$confirm('你确定要上架这道题目吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          try {
            const res = await choicePublish({ id: row.id, publishState: 1 })
            this.$message.success('上架成功')
            console.log('上架', res)
            this.loadQuestion()
          } catch (err) {
            this.$message.error('上架失败')
          }
        })
      } else if (row.publishState === 1) {
        this.$confirm('你确定要下架这道题吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          try {
            const res = await choicePublish({ id: row.id, publishState: 0 })
            this.$message.success('下架成功')
            console.log('下架', res)
            this.loadQuestion()
          } catch (err) {
            this.$message.error('下架失败')
          }
        })
      }
    },

}
</script>

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值