原理:就是把原生的input的radio类型的样式去掉,然后利用伪元素实现
![](https://i-blog.csdnimg.cn/blog_migrate/14c9eaa6d5ef416220d624aa72c6cdee.png)
border-radius:设置50%就成圆形
代码
<template>
<div class="changeOver">
<label>
<input type="radio" name="original" checked /><span>第一个</span>
</label>
<label>
<input type="radio" name="number" class="radio" checked /><span
>第一个</span
>
</label>
<label>
<input type="radio" name="number" class="radio" /><span>第二个</span>
</label>
</div>
</template>
<script>
export default {};
</script>
<style>
.changeOver {
display: flex;
flex-direction: column;
position: absolute;
background: #fff;
top: 8px;
left: 16px;
}
label {
width: 130px;
height: 26px;
display: flex;
line-height: 26px;
}
span {
display: inline-block;
}
.radio {
width: 16px;
height: 16px;
appearance: none; /*隐藏原生单选框的样式*/
-webkit-appearance: none; /*隐藏原生单选框的样式*/
outline: none;
border-radius: 50%;
position: relative;
}
.radio:before,
.radio:after {
content: "";
display: block;
position: absolute;
border-radius: 50%;
}
.radio:before {
top: 2px;
left: 2px;
width: 14px;
height: 14px;
background: #fff;
border-radius: 50%;
border: 1px solid green;
}
.radio:after {
top: 6px;
left: 6px;
width: 5px;
height: 5px;
background-color: #fff;
border-radius: 50%;
}
.radio:checked:after {
top: 5.2px;
left: 5.5px;
width: 9px;
height: 9px;
background-color: green;
}
.radio:checked:before {
border-color: green;
}
</style>
效果图
![](https://i-blog.csdnimg.cn/blog_migrate/46fccc874c35743f671994ae94701b16.png)