时间:2021-05-23 08:08:32 | 栏目:vue | 点击:次
1.写遮罩
2.定义data
3.写事件
4.效果图
补充知识:vue使用vant编辑用户性别
我就废话不多说了,大家还是直接看代码吧~
<van-cell title="性别" is-link :value="user.gender===1?'男':'女'" @click="isEditGenderShow=true"></van-cell> <!-- 编辑用户性别 --> <van-action-sheet v-model="isEditGenderShow" :actions="actions" cancel-text="取消" close-on-click-action @cancel="onCancel" @select="onGenderSelect" /> <script> export default { name: "EditUserINfo", components: {}, props: {}, data() { return { isEditGenderShow: false, // name会显示出来,value是我们自己添加的 actions: [{ name: "男",value: 1 }, { name: "女",value:0 }] }; }, watch: {}, computed: { }, methods: { onGenderSelect(data) { this.user.gender=data.value this.isEditGenderShow=false }, }, created() {}, mounted() {} }; </script>