switch开关如何在点击取消时恢复原先状态

354 阅读1分钟

                let title = v.showFlag?'禁用':'启用'
                this.$Modal.confirm({
                  title: title,
                  content: `是否${title}?`,
                  onOk: async() => {
                    let showFlags = !v.showFlag
                    editStoreBanner(
                    {id:v.id,
                    storeCode:v.storeCode,
                    merchantCode:this.merchantCode,
                    productId:v.productId,
                    picUrl:v.picUrl,
                    title:v.title,
                    showFlag:showFlags,
                    sortOrder:v.sortOrder
                    }).then(res =>{
                     this.$Message.success(`${title}成功`)
                     this.getStoreBannerList()
                    })
                  },
                  onCancel: async() => {
                    v.showFlag = v.showFlag?'false':'true'
                    this.getStoreBannerList()
                  },
                })