参考文档
使用 Component 构造器构造页面
微信小程序的组件只要在app.json
的pages
里注册过,就能当页面用,页面的生命周期函数直接写在methods
里就行,其他的写法还是按照组件的写法来
const component = {
methods: {
onLoad() {
console.log('onLoad');
},
onShow() {
console.log('onShow');
},
},
};
Component(component);