// pages/tabber/news/index.js Page({ /** * 页面的初始数据 */ data: { selectInfo: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { class Select { in = 1 getSelet(){ console.log(2); return 10 } } var b = new Select(); console.log(b.getSelet()); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { const query = wx.createSelectorQuery() query.select('#nav').boundingClientRect((res) => { console.log(res); this.setData({ selectInfo: res }) }) query.exec() }, })