实现非常简单,通过一个简单的判断当前数据中的选中值,点击按钮时更新数据值,重新渲染页面。
index.wxml文件
实现非常简单,通过一个简单的判断当前数据中的选中值,点击按钮时更新数据值,重新渲染页面index.wxml文件view class=' switch-type ' view class=' BTN { { currentSelectTripType==' pinche '?'active ' : ' ' } } ' bind tap=' selectedPinche ' data-id=' pinche '拼车/view view class=' BTN { { CurrentSelectTripType==' bache '?'活动: ' ' } } '绑定tap=' selectedbackoche '数据-id=' bache '包车/view /viewindex.js文件页面({ data : { ~ ~ ~ currentselecttriptype : ' pinche ',},//更新数据切换选中状态选择的英寸:函数{这个。setdata({ currentselecttriptype : e . current target t。数据集。id })},选择反馈记录:函数{这个。setdata({ currentselecttriptype : e . current target t。数据集。id })},})附上一个简单的样式索引。wxss。开关式{ display : flex}.开关型。BTN :第一个孩子{边框-右上角-半径: 0;边框-底部-右侧-半径: 0;}.开关型。BTN :最后一个孩子{边框-左上角-半径: 0;边框-底部-左侧-半径: 0;}.开关型BTN { background : # dfdfdfpadd : 10 rpx 40 rpx }。开关型。BTN。活动{边框: 2r px实心# 007 BFF背景# fff}index.js文件
页面({ data : { ~ ~ ~ currentselecttriptype : ' pinche ',},//更新数据切换选中状态选择的英寸:函数{这个。setdata({ currentselecttriptype : e . current target t。数据集。id })},选择反馈记录:函数{这个。setdata({ currentselecttriptype : e . current target t。数据集。id })},})附上一个简单的样式
index.wxss。开关型{ display: flex}。开关型。BTN :第一个孩子{边框-右上角-半径: 0;边框-底部-右侧-半径: 0;}.开关型。BTN :最后一个孩子{边框-左上角-半径: 0;边框-底部-左侧-半径: 0;}.开关型BTN { background : # dfdfdfpadd : 10 rpx 40 rpx }。开关型。BTN。活动{边框: 2r px实心# 007 BFF背景# fff}