hz-zhhq-app/pages/feature/feature9.vue

74 lines
2.0 KiB
Vue
Raw Normal View History

2025-01-22 10:53:47 +08:00
<template>
<view>
<!-- <view class="uni-padding-wrap">
</view> -->
<view class="uni-list">
<checkbox-group @change="checkboxChange">
<label class="uni-list-cell uni-list-cell-pd" v-for="item in items" :key="item.value">
<view>
<checkbox :value="item.value" :checked="item.checked" />
</view>
<view>{{item.name}}</view>
</label>
</checkbox-group>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'checkbox 复选框',
items: [{
value: 'USA',
name: '美国'
},
{
value: 'CHN',
name: '中国',
checked: 'true'
},
{
value: 'BRA',
name: '巴西'
},
{
value: 'JPN',
name: '日本'
},
{
value: 'ENG',
name: '英国'
},
{
value: 'FRA',
name: '法国'
}
],
}
},
methods: {
checkboxChange: function (d) {
var items = this.items,
values = d.detail.value;
for (var i = 0, lenI = items.length; i < lenI; ++i) {
const item = items[i]
if(values.includes(item.value)){
this.$set(item,'checked',true)
}else{
this.$set(item,'checked',false)
}
}
}
}
}
</script>
<style>
.uni-list-cell {
justify-content: flex-start
}
</style>