WXS(WeiXinScript)是小程序的一套脚本语言,结合WXML,可以构建出页面的结构,那么如何使用呢?封装common.wxs!--common.wxs--varvailFormat=function(value){returnvalue/1000+'千'}module.exports={vailFormat:vailFormat}复制代码example.wxml页面使用common.wxs/wxs是可以直接在wxml页面使用的相当于vue.js的过滤器wxml页面使用必须用wxs标签导入且需要定义module名否则无法使用如果不使用wxs就需要对数组进行循环操作dom容易出错使用wxs很简单方便且可以公用/wxssrc="common.wxs"module="common"viewwx:for="{{list}}"wx:key="{{index}}"{{common.vailFormat(item)}}/view复制代码example.jsdata:{list:[1000,2000,3000,4000]}复制代码转载于:https://juejin.im/post/5b7bc906f265da436152eb2d

TAG标签: 微信小程序小程序wxs

http://www.xiaochengxub.com/read-107676.html