const _app = getApp() // pages/story/a.ts Component({ /** * 组件的属性列表 */ properties: {}, /** * 组件的初始数据 */ data: { fold1: false, foldHeight1: 10000, fold2: false, foldHeight2: 10000, }, attached() { this.getHeight() }, /** * 组件的方法列表 */ methods: { getHeight() { const query = wx.createSelectorQuery().in(this) query.select('#fold1').boundingClientRect() query.select('#fold2').boundingClientRect() query.exec((res) => { this.setData({ foldHeight1: res[0].height, foldHeight2: res[1].height, }) }) }, toggleFold1() { this.setData({ fold1: !this.data.fold1, }) }, toggleFold2() { this.setData({ fold2: !this.data.fold2, }) }, }, })