小程序
一叶一菩提11
希望能学习进步
展开
-
小程序使用moment.js格式化时间
小程序使用moment1、下载http://momentjs.com/选moment.min.js版本2、集成将moment.min.js放在小程序工程的utils目录下强调文本 强调文本3、设置格式const moment = require('moment.min.js');function timestampToString(timestamp){ moment.local...原创 2019-01-07 16:39:10 · 5558 阅读 · 2 评论 -
小程序页面间传值
1、URL传值这种方式最常用,比如:wx.navigateTo({ url: '../detail/detail?cid='+cid+'&token='+token})这里面直接通过跳转页面的URL进行传值,然后在另一个页面进行接收:onLoad: function (opt) { console.log('cid =' + opt.cid); console.lo...原创 2019-01-07 16:56:17 · 3115 阅读 · 1 评论 -
小程序获取设备像素比
//获取设备像素比const getPixelRatio = () => { let pixelRatio = 0 wx.getSystemInfo({ success: function (res) { pixelRatio = res.pixelRatio }, fail: function () { pixelRatio = 0...原创 2019-01-07 17:58:52 · 5422 阅读 · 3 评论 -
判断是否在微信小程序环境中
if (ua.indexof('MicroMessage') == -1) {//说明不在微信中 // 走其他的逻辑} else { wx.miniProgram.getEnv(function(res) { if (res.miniProgram) { // 走在小程序的逻辑 } else { ...原创 2019-01-07 18:01:53 · 681 阅读 · 0 评论 -
小程序页面跳转传参参数值为url时参数丢失
错误类型:当参数的值为url的时候,在options中的值没有参数“?”之后字符串被截取。可以使用encodeURIComponent():函数可把字符串作为 URI 组件进行编码。let url=encodeURIComponent("http://baidu.com/?a=1&b=2")wx.navigateTo({ url: `detail?url=${url}`})...原创 2019-01-07 18:03:47 · 3145 阅读 · 0 评论 -
微信小程序使用计时器
data: { setInter: '',},//开始订单计时器startSetInter: function () { var that = this; that.data.setInter = setInterval( function () { //函数 }, 1000);},//清除计时器 即清除setInterendSetIn...原创 2019-01-07 18:05:56 · 5738 阅读 · 0 评论 -
小程序循环和嵌套循环遍历数据
data:{ reports:[ { id:1, failure_types:[ id:1, name:'xxx' ….. ] }, ],}<view wx:for-ite...原创 2019-01-07 18:08:53 · 865 阅读 · 0 评论 -
小程序获得元素的宽度、高度
小程序使图片宽高一致,显示为正方形// An highlighted block<image bindload="imageLoad" class="gridimg" style="width:100%;height:{{ imagesHeight }}px;" src="....." ></image>wx.cre原创 2019-03-07 15:24:50 · 1959 阅读 · 0 评论