在Vue如何使用自定義多選組件?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。

子組件(選項卡)
checkBoxCard.vue
<template>
<div class="checkBoxCard">
<div :class="`box ${check && 'boxCheck'}`" @click="checked(), updateData()">
{{ name }}
</div>
</div>
</template>
<script>
export default {
name: "checkBoxCard",
props: {
name: String,
checkIndex: {
type: Number,
default: null,
},
},
data() {
return {
radio: 0,
check: false,
radioName: "",
list: [],
};
},
methods: {
checked() {
if (this.radio == 1) {
this.check = false;
this.radio = 0;
} else if (this.radio == 0) {
this.check = true;
this.radio = 1;
}
},
updateData() {
if (this.radio == 1) {
this.radioName = this.name;
} else if (this.radio == 0) {
this.radioName = "";
}
this.$emit("updateSurveyData", this.radioName, this.checkIndex);
},
},
mounted() {},
created() {},
};
</script>
<style lang="scss" scoped>
.checkBoxCard {
margin-right: 15px;
display: inline-block;
margin-top: 10px;
}
.boxCheck {
color: rgba(183, 37, 37, 1);
background: bisque;
}
.box {
border: 0.55px solid #eee;
padding: 5px 10px;
font-size: 3.73333vw;
border-radius: 10px;
}
</style>
當前標題:在Vue如何使用自定義多選組件-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://chinadenli.net/article28/edscp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、微信小程序、App設(shè)計、App開發(fā)、品牌網(wǎng)站設(shè)計、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)