2020/9/27 0:00:00
泉源:不详
作者:未知
若是需要实现进来举行给按钮加上买一送一的样式,,,,或者单击就选中单个按钮,,,,只能靠css连系js举行控制了,,,,小程序暂时没有这样的控件。。。
微信小程序进来的时间自动举行按钮样式的初始化,,,,这个需要一个字段做判断,,,,加上正则表达式wxml文件:
-
<block wx:for="{{liuliangItems}}">
-
<block wx:if="{{item.one2one == 1}}">
-
<button class="{{item.changeColor?'selected2':'selected1'}}" type="default" id="{{item.price}}" data-id="{{item.name}}" data-one="{{item.one2one}}" data-orderid="{{item.id}}" data-number="1" bindtap="setPrice">{{item.name}}</button>
-
</block>
-
<block wx:else>
-
<button class="{{item.changeColor?'selected':'normal'}}" type="default" id="{{item.price}}" data-id="{{item.name}}" data-one="{{item.one2one}}" data-orderid="{{item.id}}" data-number="1" bindtap="setPrice">{{item.name}}</button>
-
</block>
-
</block>
复制代码
wxss文件
-
.normal{
-
box-sizing: border-box;
-
flex: 0 0 21%;
-
margin: 5px 5px;
-
height: 50px;
-
color:#1aad19;
-
border:1px solid #1aad19;
-
background-color:transparent;
-
}
-
.selected{
-
box-sizing: border-box;
-
flex: 0 0 21%;
-
margin: 5px 5px;
-
height: 50px;
-
background-color: #F75000;
-
color: white;
-
}
-
.selected1{
-
box-sizing: border-box;
-
flex: 0 0 21%;
-
margin: 5px 5px;
-
height: 50px;
-
background-color: transparent;
-
border:1px solid #1aad19;
-
color:#1aad19;
-
background-image: url(https://wxcx.llzt.net/images/hot.png) ;
-
background-position:31px 0px;
-
background-repeat:no-repeat;
-
background-size:62%;
-
}
-
.selected2{
-
box-sizing: border-box;
-
flex: 0 0 21%;
-
margin: 5px 5px;
-
height: 50px;
-
background-color: #F75000;
-
color: white;
-
background-image: url(https://wxcx.llzt.net/images/hot.png);
-
background-position:31px 0px;
-
background-repeat:no-repeat;
-
background-size:62%;
-
}
现在的要领把荟萃举行循环,,,,然后获取目今点击的这个按钮举行较量,,,,然后举行样式的修改
-
for (var i = 0; i < this.data.liuliangItems.length; i++) {
-
if (e.target.dataset.orderid == this.data.liuliangItems[i].id) {
-
txtArray1[i] = {
-
id: this.data.liuliangItems[i].id, changeColor: true,
-
price: this.data.liuliangItems[i].price, name: this.data.liuliangItems[i].name,
-
one2one: this.data.liuliangItems[i].one2one
-
}
-
} else {
-
txtArray1[i] = {
-
id: this.data.liuliangItems[i].id, changeColor: false,
-
price: this.data.liuliangItems[i].price, name: this.data.liuliangItems[i].name,
-
one2one: this.data.liuliangItems[i].one2one
-
}
-
}
-
}
【本站声明】
1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,,,由于未联系到知识产权人或未发明有关知识产权的挂号,,,,若有知识产权人并不肯意我们使用,,,,若是有侵权请连忙联系。。。
2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,,,仅系客观性形貌,,,,如您需要相识该类商品/服务详细的资讯,,,,请您直接与该类商品/服务的提供者联系。。。
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。。KESION 一直通过手艺立异,,,,提供产品和服务,,,,助力企业向数字化转型,,,,通过科技驱动商业刷新,,,,让商业变得更智慧!