import { getNodeRect, nextTick } from "@utils/tools"; const systemInfo = wx.getSystemInfoSync(); const rpx = systemInfo.windowWidth / 750; // 头像组件 Component({ properties: { row: { type: Number, value: 3, }, lineHeight: { type: Number, value: 60, }, }, data: { initOk: false, isFolded: false, noNeedFold: false, }, lifetimes: { ready() { this.init(); }, }, methods: { async init() { await nextTick(); const { height } = await getNodeRect("cnt", this); const { row, lineHeight } = this.data; let noNeedFold = height / row < lineHeight * rpx||height / row == lineHeight * rpx; this.setData({ noNeedFold, isFolded: !noNeedFold, initOk: true, }); }, shiftFold() { let { isFolded } = this.data; isFolded = !isFolded; this.setData({ isFolded }); }, }, });