上架功能两种写法的区别

文章讨论了两种在Vue.js应用中执行上架操作时的警告确认方法。第一种方式确保用户点击确定后才执行上架并显示成功消息,而第二种方式可能导致在警告框仍显示时就触发成功提示。这两种写法涉及Promise和异步控制流程。
摘要由CSDN通过智能技术生成

第一种写法:

        /**
         * 上架
         */
        grounding (row) {
          let _this = this;
          this.$confirm('是否确认上架该数据项?', '警告', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(function () {
            return getTopNext(row.id,null,1,store.getters.userInfo.userId);
          }).then(data => {
            _this.page.currentPage = 1;
            _this.getList(this.page);
            _this.showToal('提示', '上架成功', 'success');
          })
        },

上面得写法可以点击上架之后提示警告:

点击确定之后,才会提示上架成功

第二种写法:

        /**
         * 上架
         */
        grounding (row) {
          let _this = this;
          this.$confirm('是否确认上架该数据项?', '警告', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          getTopNext(row.id,null,1,store.getters.userInfo.userId).then(data => {
            _this.page.currentPage = 1;
            _this.getList(this.page);
            _this.showToal('提示', '上架成功', 'success');
          })
        },

 这种写法会导致,在出现警告框的时候,就会提示上架成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值