微信小程序开发之组件复用机制
新建复用文件,另外需要注册 behavior
例如:
在behavior.js文件中写入方法,并向外暴露出去
写法一:
module.exports=Behavior({data: {num: 1},lifetimes: {created() {console.log(1);}}
})
写法二:
const behavior = Behavior({data: {num: 1},lifetimes: {created() {console.log(1);}}
})export default behavior