微信小程序wxs的使用(当页面数据渲染前添加js操作)

JavaScript028

微信小程序wxs的使用(当页面数据渲染前添加js操作),第1张

小程序的wxs功能可以让wsmxl可以调用和编写js,基本上wxs和JS无关系,只是语法形式很相似。 如下写了两个关于时间的函数,并将它们导出, <wxs module="m1"> var getMax = function(flightDate) {     var now = getDate().getDate()     var flDate = getDate(flightDate).getDate()     if( now <flDate ){       return '+1'     }else{       return ''     } } var formartTime = function(flightDate,format){   if(flightDate){     var realDate = getDate(flightDate)     function timeFormat(num) {       return num <10 ? '0' + num : num     }     var date = {       "Y": timeFormat(realDate.getFullYear()),       "M": timeFormat(realDate.getMonth() + 1),       "d": timeFormat(realDate.getDate()),       "h": timeFormat(realDate.getHours()),       "m": timeFormat(realDate.getMinutes()),       "s": timeFormat(realDate.getSeconds()),       "q": Math.floor((realDate.getMonth() + 3) / 3),       "S": realDate.getMilliseconds(),     }     if (!format) {       format = "yyyy-MM-dd hh:mm:ss"     }     if( format == 'hh:mm' ){         return date.h+':'+date.m     }else{         return date.h+':'+date.m     }   }else{     return false   } } module.exports.getMax = getMax module.exports.formartTime = formartTime </wxs> 可在页面添加如下使用: m1.formartTime()  m1.getMax()

我这样改了:#includeusingnamespacestdintmain(){intn[10]intlink[10]inth=-1intm,c=0intp=0while(cin>>m&&p++m&&p++>m&&p++<10)”