微信小程序checkbox的排列方向
参考链接https://blog.csdn.net/wangshop_11/article/details/54236745
关于微信小程序中的checkbox组件,需要在checkbox-grop包裹下,在添加一个标签来包裹,在不考虑排列放下的前提下默认排列是水平的
module.js
Page({data: {imageUrls: ['http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg','http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg','http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'],inter: 2000,items: [{ name: 'USA', value: '美国' },{ name: 'CHN', value: '中国', checked: 'true' },{ name: 'BRA', value: '巴西' },{ name: 'JPN', value: '日本' },{ name: 'ENG', value: '英国' },{ name: 'TUR', value: '法国' },]},checkboxChange: function (e) {console.log('checkbox发生chang事件', e.detail.value)}
})module.wxml
<checkbox-group bindchange="checkboxChange"><label wx:for="{{items}}"><checkbox value="{{item.name}}" checked="{{item.checked}}">{{item.value}}</checkbox></label>
</checkbox-group>
当checkbox在label标签包裹下需要垂直排列的时候
module.wxml
直接在label属性上用style=“display:flex;”,在WXSS文件用display: flex;
<checkbox-group bindchange="checkboxChange"><label style="display:flex;" wx:for="{{items}}"><checkbox value="{{item.name}}" checked="{{item.checked}}">{{item.value}}</checkbox></label>
</checkbox-group>
当checkbox在view标签包裹下需要垂直排列的时候
module.wxml
<checkbox-group bindchange="checkboxChange"><view style="flex-direction:column;" wx:for="{{items}}"><checkbox value="{{item.name}}" checked="{{item.checked}}">{{item.value}}</checkbox></view>
</checkbox-group>