微信小程序,无法实现点击左边,字体和背景变色
Uotogelety
Uotogelety 2020-05-09 18:28:14
[JavaScript讨论组]

Page({

data: {

activeId:2,

typelist:[

{

id:1,

title:"家具"}, {

id:2,

title: "家具"}, {

id:3,

title: "家具"}, {

id:4,

title: "家具" }, {

id:5,

title: "家具"

}

]

},

onLoad: function (options) {

},

selectType(e){

this.setData({

activeId: e.currentTarget.dataset.id

})

}

})

------------------------------------

wxml

<view class="container">

<view class="left">

<view  wx:for="{{typelist}}" class="{{itme.id==activeId?'active':''}}"

bindtap="selectType" data-Id="{{item.id}}">

{{item.title}}

</view></view>

<view class="right"></view>

</view>

-----------------------------------

wxss

.left{

width: 250rpx;

background: #eee;

height: 1000rpx;

}

.left view{

padding: 10px 0px;

text-align: center;

}

.left view.active{

color: burlywood;

background: #fff;

}

.right{

flex: 1;

}

.comtainer{

display: flex;

min-height: 100vh;

}

Uotogelety
Uotogelety

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号