微信小程序-wxml模板页面逻辑运算

通常在utils中创建一个.wxs后缀的文件(例如:fn.wxs)

function addition(a,b){
	return Number(a)+Number(b);
}
module.exports = {
	addition:addition,
}

需要逻辑运算的wxml页面

<wxs src="../../utils/fn.wxs" module="tool" />
<view class="nowpage">{{tool.addition(page.index,1)}}</view><!-- 得到page.index+1的运算结果 -->
原文地址:https://www.cnblogs.com/sunday123/p/13152157.html