微信小程序


全局变量使用

事件冒泡

bind事件向上冒泡

catch事件可以阻止向上冒泡

引入模板

json文件中注册 { "usingComponents": { "search": "/components/search/search" }}

①wxml文件: 

调用地方: 

                 

css调用:  @import ' ../../index.wxss ';

②直接使用引入所有模板, 定义模板内用{{变量}}在data取值

引入不了 

跳转页面  https://cloud.tencent.com/developer/article/1475825

wx.redirectTo({ url: '/page'//页面路径})   //会关闭当前页面

wx.navigateTo({ url: '/page/home/home?name='+name })不会关闭当前页面

不会关闭当前页面

wx.reLaunch({ url: '/page'//页面路径})  // 会关闭所有页面

wx.switchTab (url: ' /page ')  // 可以跳转到taber  list  path的路径

获取栈中所有的页面: var get = getCurrentPages()

请求方法:  wx.request({ url:'  ', data: {  }, success:function(res){  } })

css单位rpx:  对应iphone6 0.5px 自适应全端

鼠标点击改颜色:  hover-class="box_hover" hover-start-time="0" hover-stay-time="0" hover-stop-propagation

自定义属性

本地储存

存储:wx.setStorageSync('token', res.data.object)

获取:wx.getStorageSync('token')

wx.setStorage({ key:"key",  data:"value", success:function(res){console.log(res)},  fail:function(res){console.log(res)}, complete:function(res){console.log(res)}, })

wx.getStorage( {  key:'key',  success:function(res){  console.log(res)//Object {errMsg: "getStorage:ok", data: "value1"}  },  fail:function(res){console.log(res)},  complete:function(res){console.log(res)} })

提示框

    wx.showToast({ title: '输入完成',image: './error,png'  }) // 默认是成功√号

wx:for遍历渲染

wx:for="{{home_list}}"   增加key键:    wx:key="id"   改变key值:    wx:for-item="da"

你可能感兴趣的:(微信小程序)