微信小程序开发常用技巧总结

圆形头像

<image src="/images/avatar.png" style='width:200rpx; height:200rpx; border-radius: 50%;'></image>

拨打电话

<text bindtap='call' style='color:#1c8cff;'>0571-10086</text>
call() {
  wx.makePhoneCall({
    phoneNumber: '0571-10086'
  })
}

空格及换行

<text decode="{{true}}">
  A p p B l o g . C N \n你    好
</text>
<text>你\t好!AppBlog.CN\n这是第二行</text>

PS:必须在text标签中!

PS:经测试,多个\t只能显示一个空格

对象与字符串互转

JSON.stringify(user)
JSON.parse(json)

对象传递

wx.navigateTo({
  url: '/pages/index/index?from=index&user=' + JSON.stringify(this.data.user)
})

var user = JSON.parse(options.user);

元素覆盖:position:absolute

<view style="position:absolute; left:0rpx; top:0rpx; width:100%; background-color:rgba(0,0,0,.25); visibility:{{visibility}};">
  <image src="/images/share_tip.png"></image>
</view>

回退至最前页面

var pages = getCurrentPages(); //获取当前页面信息栈
console.log("pages.length: " + pages.length)
wx.navigateBack({
  delta: pages.length
})
上一篇 微信小程序集成Markdown
下一篇 微信小程序开发经验总结
目录
文章列表
1 Atlas通过RemoteTransactor加载并运行远程Bundle
Atlas通过RemoteTransactor加载并运行远程Bundle
2
Moss(莫斯) - Spring Cloud体系的服务治理平台
Moss(莫斯) - Spring Cloud体系的服务治理平台
3
Spring Boot弃用Tomcat选择Undertow作为容器
Spring Boot弃用Tomcat选择Undertow作为容器
4
Android电源锁和屏幕锁帮助类
Android电源锁和屏幕锁帮助类
5
nginx-rtmp流媒体服务器搭建
nginx-rtmp流媒体服务器搭建
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。