生命周期
1.分类
2.应用生命周期函数
3.页面周期函数
WXS脚本
与JS的区别没太理解
1.使用内嵌脚本
/*wxml*/
<view>{{m1.toUpper(username)}}</view>
<wxs module="m1">
module.exports.toUpper = function(str){
return str.toUpperCase()
}
</wxs>
2.外联wxs脚本
定义外联脚本
/*tools.wxs*/
function strLower(str) {
return str.strLowerCase()
}
module.exports = {
strLower : strLower
}
使用外联脚本,利用脚本的方法
/*wxml*/
<view>{{m2.toLower(country)}}</view>
<wxs src="../../utils/tools.wxs" module="m2"></wxs>