You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// pages/fenlei/fenlei.js
Page ( {
data : {
cateItems : [
{
cate _id : 1 ,
cate _name : "小说" ,
ishaveChild : true ,
children :
[
{
child _id : 1 ,
name : '福尔摩斯' ,
image : "/pages/index/image/xs1.jpg"
} ,
{
child _id : 2 ,
name : '莫泊桑' ,
image : "/pages/index/image/xs2.jpg"
} ,
{
child _id : 3 ,
name : '盗墓笔记' ,
image : "/pages/index/image/xs3.jpg"
} ,
{
child _id : 4 ,
name : '明朝那些事' ,
image : "/pages/index/image/xs4.jpg"
}
]
} ,
{
cate _id : 2 ,
cate _name : "科学期刊" ,
ishaveChild : true ,
children :
[
{
child _id : 1 ,
name : '世界百科' ,
image : "/pages/index/image/kxqk1.jpg"
} ,
{
child _id : 2 ,
name : '动物百科' ,
image : "/pages/index/image/kxqk2.jpg"
} ,
{
child _id : 3 ,
name : '趣味科学' ,
image : "/pages/index/image/kxqk3.jpg"
}
]
} ,
{
cate _id : 3 ,
cate _name : "儿童书籍" ,
ishaveChild : true ,
children :
[
{
child _id : 1 ,
name : '父与子全集' ,
image : "/pages/index/image/etsj1.jpg"
} ,
{
child _id : 2 ,
name : '丁丁历险记' ,
image : "/pages/index/image/etsj2.jpg"
} ,
{
child _id : 3 ,
name : '美丽星空' ,
image : "/pages/index/image/etsj3.jpg"
} ,
{
child _id : 4 ,
name : '小虎神探队' ,
image : "/pages/index/image/etsj4.jpg"
}
]
} ,
{
cate _id : 4 ,
cate _name : "计算机" ,
ishaveChild : true ,
children : [
{
child _id : 1 ,
name : 'Java Web' ,
image : "/pages/index/image/java.jpg"
} ,
{
child _id : 2 ,
name : '计算机网络' ,
image : "/pages/index/image/jsswl.jpg"
} ,
]
}
] ,
curNav : 1 ,
curIndex : 0
} ,
//事件处理函数
switchRightTab : function ( e ) {
// 获取item项的id, 和数组的下标值
let id = e . target . dataset . id ,
index = parseInt ( e . target . dataset . index ) ;
// 把点击到的某一项, 设为当前index
this . setData ( {
curNav : id ,
curIndex : index
} )
}
} )