须要实现的功能效果以下javascript
axml文件代码html
{{item.helpTitle}}
{{item.helpContent}}
js文件内容java
Page({
data: {
helpList:[
{
helpTitle:"item-title1",
helpContent:"item-content1"
},
{
helpTitle:"item-title2",
helpContent:"item-content2"
},
{
helpTitle:"item-title3",
helpContent:"item-content3"
}
],
showIndex:"-1"
},
clickHandle(e){
console.log(e.currentTarget.dataset.index);
if (e.currentTarget.dataset.index != this.data.showIndex) {
this.setData({
showIndex: e.currentTarget.dataset.index
})
} else {
this.setData({
showIndex: "-1"
})
}
}
});