The micro-channel applet wxml {} {} function is used

Because frequently encountered in dynamic binding function data when wxml micro letter, achieve a similar effect filter vue, after which access to the document can not be found directly use functions to do by a .wxs file
https: //developers.weixin. qq.com/miniprogram/dev/reference/wxs/01wxs-module.html

New root directory utils / utils.wxs

There does not seem to support grammar es6, and many basic data types such as date of usage is changed, specifically to see the document

// 作用于wxml中的函数
var formatTime = function(ts) {
  var time = getDate(parseInt(ts))
  var y = time.getFullYear()
  var m = time.getMonth() + 1
  var d = time.getDay()
  console.log(ts,time, y,m,d)
  return y+'/'+m+'/'+d
}

module.exports = {
  formatTime: formatTime
}

use

active.wxml
<wxs src="../../utils/utils.wxs" module ="utils"/>
        <text>起止时间{{utils.formatTime(item.starttime)}}---{{utils.formatTime(item.endtime)}}</text>

Guess you like

Origin blog.csdn.net/weixin_34342992/article/details/90861353