- Determine whether the rendering wx: if
<view wx:if="{{a>1}}"> 1 </view>
<view wx:elif="{{a>2}}"> 2 </view>
<view wx:else> 3 </view>
- The value of listening input box
<input bindinput='watchPassWord' type='password' class="weui-input" placeholder="请输入密码" />
Page({
// 监听输入
watchPassWord: function (event) {
console.log(event.detail.value);
}
})
-
As a separate title page setup json
I want to modify the navigation bar of the whole program, the
app.json
revised document
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "修改,改变程序导航栏名称",
"navigationBarTextStyle": "black"
}
I would like to modify a single page navigation bar, json file in the folder you want to modify the page, fill in the following code to modify
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "单独页面",
"navigationBarTextStyle": "black"
You may also be dynamically loaded into the js
onLoad: function (options) {
wx.setNavigationBarTitle({
title: '当前页面' //修改title
})
},
- Jump route passing parameters
//A页面 实现跳转
wx.navigateTo({
url: '/page/b/b?data1=' + a + '&data2=' + b
})
//B页面 接收参数
onLoad: function (options) {
let data1 = options.data1;
let data2 = options.data2;
console.log(data1);//1
console.log(data2);//2
}
- -Data small micro-channel assignment procedures and values
//页面js文件中这么写
Page({
data: {
message: 'Hello MINA!'
}
})
//页面wxml文件中这么写
<view> {{ message }} </view>
//页面js中修改data变量
function setData(){
var that = this;
that.setData({
message: '新消息'
})
}
//页面js中获取data变量
function getData(){
var that = this;
console.log(that.data.message)
}
- Global Variables
在app.js中设置全局变量
//app.js
App({
onLaunch: function () {
this.globalData = {
test: 1
}
}
})
//或者
App({
onLaunch: function () {
},
globalData :{
}
})
//获取全局变量
var app = getApp();
var test = app.globalData.test;
//更新全局变量
var app = getApp();
app.globalData.test = 2;