<el-radio-group v-model="uploadStatus" class="upload-status-radio"> <el-radio label="0" class="green" @click.native="clickRadio($event, 0)">成功</el-radio> <el-radio label="1" class="red" @click.native="clickRadio($event, 1)">失敗</el-radio> </el-radio-group>
data () { return { uploadStatus: '-1' } }, methods: { /** * 點擊單選框取消選中狀態的處理 * @param e 原生e * @param index */ clickRadio (e, index) { if (e.target.tagName === 'INPUT') return // 由於原生click事件會執行兩次,第一次在label標籤上,第二次在input標籤上,故此處理 if (this.uploadStatus === index.toString()) { this.uploadStatus = '-1' } }, }