小程序模板
/**header.js**/
function init(){
var that = this ;
//header中相应的数据
that.setData({
logo: '../../img/logo.png',
a:""
}) ;
//header中相应的 操作
that.a = function(event){
} ;
that.b = function(event){
}
that.c = function(event){
}
} ;
module.exports = {
init: init
} ;
<!--在other.wxml模块引入header.wxml-->
<include src="../include/header.wxml"/>
/**在other.wxml模块引入header.js**/
var header = require('../include/header.js');
Page({
data:{
},
onLoad:function(options){
header.init.apply(this,[]);// this关键字必须传进去 这样才能使header.js中的数据和函数注入到这个模块
}
})