28 lines
604 B
TypeScript
28 lines
604 B
TypeScript
// behaviors/common.ts 全局混入语言切换函数
|
|
export const commonBehavior = Behavior({
|
|
|
|
data: {
|
|
inputWidth: 0,
|
|
inputWidthW: 0,
|
|
safeAreaTop: 47
|
|
},
|
|
onLoad() {
|
|
this.initInputWidth();
|
|
},
|
|
|
|
// 2. 给 【Component 组件】 使用
|
|
attached() {
|
|
this.initInputWidth();
|
|
},
|
|
methods: {
|
|
// 初始化组件宽度 / 头部高度
|
|
initInputWidth() {
|
|
const app = getApp();
|
|
this.setData({
|
|
inputWidth: app.globalData.inputWidth,
|
|
inputWidthW: app.globalData.inputWidthW,
|
|
safeAreaTop: app.globalData.safeAreaTop,
|
|
})
|
|
},
|
|
}
|
|
}); |