const getHeight = require("../../utils/getRheRemainingHeight"); Page({ /** * 页面的初始数据 */ data: { scrollHeight: 0, //滚动区域高度 searchContent: "", //搜索内容 mainActiveIndex: 0, //分类选择器打开分类的下标 activeId: null, //分类选择器选择id items: [{ text: '所有城市', children: [{ text: '温州', id: '温州', }, { text: '杭州', id: '杭州', }, ], }, { text: '可选城市', children: [{ text: '嘉兴', id: '嘉兴', }, { text: '台州', id: '台州', }, ], }, ] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) {}, onClickNav({ detail = {} }) { this.setData({ mainActiveIndex: detail.index || 0, }); }, onClickItem({ detail = {} }) { const activeId = this.data.activeId === detail.id ? null : detail.id; console.log(activeId) this.setData({ activeId }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { //滚动区域高度 getHeight.getHeight('.menu', this).then(res => { this.setData({ scrollHeight: res }) }) }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, /** * 用户分享到朋友圈 */ onShareTimeline() { } })