Open lengziyu opened 5 years ago
在template使用类似vue的filter功能,在小程序template里无法调用methods里面的函数,无法使用定义的全局函数,例如在onLoad()里可以使用this.isArray()调用函数,在template却无法调用。
this.isArray()
只能用wxs,WePY 从1.7.x 版本开始支持 wxs 语法。
module.exports = { text: 'This is from wxs', filter: function (num) { return num.toFixed(2); } };
<template> <text>{{m1.text}}</text> <text>{{m1.filter(num)}}</text> </template> <script> import wepy from 'wepy'; // 只能相对路径 import mywxs from '../wxs/mywxs.wxs'; export default class Index extends wepy.page { data = { num: 10 }; wxs = { m1: mywxs } }; </script>
在template使用类似vue的filter功能,在小程序template里无法调用methods里面的函数,无法使用定义的全局函数,例如在onLoad()里可以使用
this.isArray()
调用函数,在template却无法调用。只能用wxs,WePY 从1.7.x 版本开始支持 wxs 语法。
mywxs.wxs
index.wpy