<template>
<view>
<view @click="paytype('1')">
<button>1</button>
<radio :checked="type =='1'" />
</view>
<view @click="paytype('2')">
<button>2</button>
<radio :checked="type =='2'" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
type: "",
}
},
methods: {
paytype(i) {
console.log('选中' + i);
this.type = i
}
}
}
</script>
利用:checked="type =='2'" 来使checked为真,用于例如选择支付方式等场景
文章评论