uniapp radio 弹出取消后恢复以前的选择

<view>
        <radio-group class="radioBox"  @change="radioChange"   v-if="hackReset" >
          <label class="itemRadio uni-list-cell uni-list-cell-pd" >
            <view>
              <radio :value="1"  :checked="select_one==='1'" />
            </view>
            <view>testone</view>
          </label>
          <label class="itemRadio uni-list-cell uni-list-cell-pd" >
            <view>
              <radio :value="2" :checked="select_one==='2'" />
            </view>
            <view>testtwo</view>
          </label>
        </radio-group>
      </view>
radioChange: function(evt) {

      var that = this
      if(evt.detail.value == 1){
        if(that.select_one == '1'){
          return false;
        }
      }else{
        if(that.select_one == '2'){
          return false;
        }
      }
      uni.showModal({
        title: '提示',
        content: '确认切换吗?',
        success: function(res) {
          if (res.confirm) {
            that.submit(evt.detail.value)
          }else {
            that.refresh()
          }
        }
      })
    },

    refresh() {
      let that = this
      this.hackReset = false
      setTimeout(function() {
        that.hackReset = true
      }, 1)
    },

posted @ 2023-02-27 12:57  Bashuslovakia  阅读(220)  评论(0编辑  收藏  举报