创建网站超市,中小企业网站制作塞尼铁克,免费的查企业的网站,南通专业做网站公司先看最终效果#xff1a;
思路#xff1a;
一、
首先准备好按钮内容#xff1a;const a [one,two,three] 将按钮循环展示出来#xff0c;并设置一些样式#xff0c;将按钮背景透明#xff1a;
button v-for(item,index) in a :keyin…先看最终效果
思路
一、
首先准备好按钮内容const a [one,two,three] 将按钮循环展示出来并设置一些样式将按钮背景透明
button v-for(item,index) in a :keyindex{{ item }}/buttonbutton {width: 100px;height: 40px;border-radius: 20px;border: 1px solid red;background-color: transparent;
}二、
在外面包裹一个div设置背景颜色border-radius与按钮一致按钮边框和背景透明这样背景是什么颜色/边框按钮就会是什么颜色/边框 div classcontainer button v-for(item,index) in a :keyindex{{ item }}/button/div.container {margin:40px;border: 1px solid transparent;display: inline-block;padding: 0;border-radius: 20px;height: 40px;background-color: #ECEFEE;
}
button {width: 100px;height: 40px;border-radius: 20px;border: 1px solid transparent;background-color: transparent;
}三、
最后加上选中效果因为是单选所以必须保证每次只能选中一个动态绑定class
div classcontainer button v-for(item,index) in a :keyindex :classradioitem?yes: clickhandleClick(item){{ item }}/button
/divconst radio ref(one) // 默认选中
const handleClick (value) {radio.value value
}.container{margin:40px;border: 1px solid transparent;display: inline-block;padding: 0;border-radius: 20px;height: 40px;background-color: #ECEFEE;
}
button{width: 100px;height: 40px;border-radius: 20px;border: 1px solid transparent;background-color: transparent;
}
.yes {background: red;color: white;
}over