FWQ
微信小程序之定义全局数据、函数复用、模版等实例介绍
这篇文章主要介绍了微信小程序之定义全局数据、复用、模版等的相关资料,需要的朋友可以参考下 微信小程序 定义全局数据、函数复用、模版等问题总结: 1.如何定义全局数据 在app.的App({})中定义的数据或函数都是全局的,在页面中可以通过var app = getApp(); app.function/的方式调用,不过我们没有必要再app.js中定义。 2.如何实现代码的复用 函数的复用: test.js test: function(){ } module.exports={ test:test } other.js var common = require('test.js'); page({ common.test() }) 登录后复制 模板: <template> <view> odd </view></template><template> <view> even </view></template><block> <template></template></block>…