1.模板的创建及引用
模板只包括 wxml和wxss两个文件 命名以 ...-template
- 创建模板
<template name="movieTemplate">
</template>
- 导出渲染模板
<import src="../movie/movie-template.wxml" />
@import "../movie/movie-template.wxss";
- 使用模板
<template is="movieTemplate" data="{ {...movie}}"/>
2.工具类的封装与使用
//util.js
function http(url, callBack) {
wx.request({
url: url,
method: 'GET',
header: {
"Content-Type": "json"
},
success: function (res) {
callBack(res.data);
},
fail: function (error) {
console.log(error)
}
})
}
module.exports = {
http: http,
}
//引用位置
var util = require('../../utils/util.js')
util.http(dataUrl, this.processDoubanData)
3.全局存储
全局变量
app.globalDat

本文介绍了微信小程序中模板的创建、引用及页面间的交互,包括如何创建和使用模板,以及如何进行全局存储。同时,文章还讨论了app.globalData与本地缓存wx.setStorageSync的区别,并展示了ES6类的使用。
最低0.47元/天 解锁文章
505

被折叠的 条评论
为什么被折叠?



