首页
归档
笔记
树洞
搜索
友言

文章详情

Interesting People Record Interesting.

/ JavaScript / 文章详情

vue 列表的单个按钮单个加载

Sonder
2021-02-26
536字
1分钟
浏览 (2.9k)

问题

现在是点击一个按钮整个按钮出现了加载
期望效果是是当前按钮加载

image.png

解决

获取到数据后,我自己向数组加一个字段

image.png

然后点击后设置加载状态

复制代码
onClickGoodsTop(item) {
  item.topLoading = true;
  // 设了值了,不需要用this.$set了
  // this.$set(item, 'topLoading', true)
  let p = {action: {goodsKeyNo: item.goodsKeyNo}}
  setTimeout(() => {
    xxxx.post(p).then(res =>{
      // this.$set(item, 'topLoading', false)
      item.topLoading = false;
      if(res.success) {
        this.$message.success(res.info);
        return
      }
      this.$message.info(res.info)
    })
  },500)
},
image.png

完成!

下一篇 / Vue 工作中的工具函数集合

🎯 相关文章

💡 推荐文章

🕵️‍♂️ 评论 (0)