小程序随笔

wx.showToast(OBJECT)

显示消息提示框

OBJECT参数说明:

参数类型必填说明最低版本
title String 提示的内容  
icon String 图标,有效值 "success", "loading"  
image String 自定义图标的本地路径,image 的优先级高于 icon 1.1.0
duration Number 提示的延迟时间,单位毫秒,默认:1500  
mask Boolean 是否显示透明蒙层,防止触摸穿透,默认:false  
success Function 接口调用成功的回调函数  
fail Function 接口调用失败的回调函数  
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码:

wx.showToast({
  title: '成功',
  icon: 'success',
  duration: 2000
})

wx.hideLoading()

基础库 1.1.0 开始支持,低版本需做兼容处理

隐藏 loading 提示框

wx.showLoading({
  title: '加载中',
})

setTimeout(function(){
  wx.hideLoading()
},2000)



View~Model动态绑定,联动
<!-- This is our View -->
<view> Hello {{name}}! </view>
<button bindtap="changeName"> Click me! </button>
// This is our App Service.
// This is our data.
var helloData = {
  name: 'WeChat'
}

// Register a Page.
Page({
  data: helloData,
  changeName: function(e) {
    // sent data change to view
    this.setData({
      name: 'MINA'
    })
  }
})
 

缓存读写

wx.setStorage(OBJECT)   异步方法,可以指定success、fail

wx.setStorageSync(KEY,DATA)

wx.getStorage(OBJECT)   异步方法,可以指定success、fail

wx.getStorageSync(KEY)

 

 

posted on 2017-10-26 17:11  nlh774  阅读(165)  评论(0编辑  收藏  举报