获取当前页面的参数
/**
* 页面的初始数据
*/
data: {
level_one_data: [],
level_two_data:[],
product_list:[]
}
let level_two_data = that.data.level_two_data; // 获取当前对象的值
for (var i = 0, len = level_two_data.length; i < len; i++) {
if (!level_two_id) {
if (i == 0) {
level_two_data[i]['select'] = 1;
} else {
level_two_data[i]['select'] = 0;
}
} else {
if (level_two_data[i]['id'] == level_two_id) {
level_two_data[i]['select'] = 1;
} else {
level_two_data[i]['select'] = 0;
}
}
}
// 设置二级菜单
that.setData({
level_two_data: level_two_data
});
调用当前的函数
/**
* 选择菜单一
*/
select_type_one: function (e) {
let level_one_id = e.currentTarget.dataset.id;
this.set_type_one(level_one_id);
},
set_type_one: function (level_one_id) {
// todo ...
}
转载于:https://www.cnblogs.com/jiqing9006/p/11405707.html