知識(shí)
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X(jué)表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!
您當(dāng)前位置>首頁(yè) » 新聞資訊 » 小程序相關(guān) >
小程序?qū)崿F(xiàn)展開(kāi)隱藏列表
發(fā)表時(shí)間:2020-9-28
發(fā)布人:葵宇科技
瀏覽次數(shù):68
一、實(shí)現(xiàn)思路
用戶點(diǎn)擊wxml中的某個(gè)事件后,會(huì)觸發(fā)js中的函數(shù),該函數(shù)可以動(dòng)態(tài)修改css樣式,效果如圖所示。
二、代碼
wsml:
<view class='display-title' catchtap="showHidden" data-id="1">
<image class="list-icon-left" src="../../images/list.png"></image><text class="title-text">宣傳教育</text>
<image class="list-icon-right" src="{{arrow[0].url}}"></image>
</view>
<view class="{{arrow[0].css}}">
<block wx:for="{{propagate}}" wx:key="index">
<view wx:if="{{item.type == 1}}">
<view class='text-content' catchtap="catchTapPropagate" data-id="{{item.id}}">{{item.title}}</view>
</view>
</block>
</view>
<view class='display-title' catchtap="showHidden" data-id="2">
<image class="list-icon-left" src="../../images/list.png"></image><text class="title-text">法制法規(guī)</text>
<image class="list-icon-right" src="{{arrow[1].url}}"></image>
</view>
<view class="{{arrow[1].css}}">
<block wx:for="{{propagate}}" wx:key="index">
<view wx:if="{{item.type == 2}}">
<view class='text-content' catchtap="catchTapPropagate" data-id="{{item.id}}">{{item.title}}</view>
</view>
</block>
</view>
<view class='display-title' catchtap="showHidden" data-id="3">
<image class="list-icon-left" src="../../images/list.png"></image><text class="title-text">案例警示</text>
<image class="list-icon-right" src="{{arrow[2].url}}"></image>
</view>
<view class="{{arrow[2].css}}">
<block wx:for="{{propagate}}" wx:key="index">
<view wx:if="{{item.type == 3}}">
<view class='text-content' catchtap="catchTapPropagate" data-id="{{item.id}}">{{item.title}}</view>
</view>
</block>
</view>
js:
data: {
arrow:[{url:"../../images/down.png",css:"content-hidden",state:0},
{url:"../../images/down.png",css:"content-hidden",state:0},
{url:"../../images/down.png",css:"content-hidden",state:0}],
}
showHidden: function (e) {
var that=this
var id = e.currentTarget.dataset.id;
console.log(that.data.arrow)
if(id==1){
if(that.data.arrow[0].state==0){
that.setData({
'arrow[0].url':'../../images/up.png',
'arrow[0].css':'content-show',
'arrow[0].state':1,
})
}else{
that.setData({
'arrow[0].url':'../../images/down.png',
'arrow[0].css':'content-hidden',
'arrow[0].state':0,
})
}
}else if(id==2){
if(that.data.arrow[1].state==0){
that.setData({
'arrow[1].url':'../../images/up.png',
'arrow[1].css':'content-show',
'arrow[1].state':1,
})
}else{
that.setData({
'arrow[1].url':'../../images/down.png',
'arrow[1].css':'content-hidden',
'arrow[1].state':0,
})
}
}else{
if(that.data.arrow[2].state==0){
that.setData({
'arrow[2].url':'../../images/up.png',
'arrow[2].css':'content-show',
'arrow[2].state':1,
})
}else{
that.setData({
'arrow[2].url':'../../images/down.png',
'arrow[2].css':'content-hidden',
'arrow[2].state':0,
})
}
}
},
wxss:
.content-hidden{
width: 100%;
font-size: large;
font-family: Georgia, 'Times New Roman', Times, serif;
display: none;
}
.content-show{
width: 100%;
font-size: large;
font-family: Georgia, 'Times New Roman', Times, serif;
display: block;
}
相關(guān)案例查看更多
相關(guān)閱讀
- 云南電商網(wǎng)站建設(shè)
- 網(wǎng)站建設(shè)公司哪家好
- web開(kāi)發(fā)技術(shù)
- SEO
- 日歷組件
- 云南建設(shè)廳官方網(wǎng)站
- 排名
- 網(wǎng)站搭建
- 云南網(wǎng)站建設(shè)服務(wù)公司
- 網(wǎng)站建設(shè)特性
- 人人商城
- 云南旅游網(wǎng)站建設(shè)
- 保山小程序開(kāi)發(fā)
- 表單
- 云南網(wǎng)站建設(shè)
- 做小程序被騙
- 汽車報(bào)廢回收軟件
- 云南etc小程序
- typescript
- 網(wǎng)站建設(shè)需要多少錢
- 開(kāi)通微信小程序被騙
- 二叉樹(shù)
- 昆明網(wǎng)站設(shè)計(jì)
- 報(bào)廢車拆解回收管理系統(tǒng)
- 報(bào)廢車回收管理軟件
- 怎么做網(wǎng)站
- 商標(biāo)注冊(cè)
- 小程序開(kāi)發(fā)公司
- 汽車回收管理系統(tǒng)
- 云南小程序哪家好