In VUE, use the radio button el-radio-button of the ElementUI component to realize the function of deselecting the second click

The page style is:

The html code is:

日志等级:
<el-radio-group v-model="logLevel">
   <el-radio-button label="DEBUG" @click.native.prevent="changeLogLevel('DEBUG')">DEBUG</el-radio-button>
   <el-radio-button label="INFO" @click.native.prevent="changeLogLevel('INFO')">INFO</el-radio-button>
   <el-radio-button label="ERROR" @click.native.prevent="changeLogLevel('ERROR')">ERROR</el-radio-button>
</el-radio-group>

The js code is: (remember to declare loglevel: "" in data)

    changeLogLevel(val) {
      if (this.logLevelChecked && val == this.logLevel) {
        this.logLevelChecked = "";
        this.logLevel = "";
        this.getLogAggregation();
      } else {
        this.logLevelChecked = 1;
        this.logLevel = val;
        this.getLogAggregation();
      }
    }

Guess you like

Origin blog.csdn.net/qq_56715703/article/details/131965495