"navigationBarTitleText": "测试title"
<view class="bg1">微信</view>
<view>
<!-- 使用index.js 的数据-->
我是微信2 之 {{ name }}
<text style="color:#ff5">我是text1</text><text>我是text1</text>
</view>
.bg1 {
background: pink;
}
Page({
/**
* 页面的初始数据
*/
data: {
name:"xzl"
},
})
index.json 文件
{
"usingComponents": {},
"navigationBarTitleText": "测试title"
}
App({
onLaunch: function () {
console.log('app onLaunch');
},
onShow: function (options) {
console.log("app onShow");
},
onHide: function () {
console.log("app onHide");
},
onError: function (msg) {
console.log("app onError");
}
})
注意点:生命周期执行顺序
编译的时候
切换后台的时候(从页面切换后台时候如下)
后台切换页面时(从后台切换页面时候如下)
事件:
Page({
data: {
name:"xzl"
},
onLoad: function (options) {
console.log("page onLoad");
},
onReady: function () {
console.log("page onReady");
},
onShow: function () {
console.log("page onShow");
},
onHide: function () {
console.log("page onHide");
},
onUnload: function () {
console.log("page onUnload");
},
onPullDownRefresh: function () {
},
onShareAppMessage: function () {
}
})
"pages/center/index"
即可!{
"pages":[
"pages/index/index",
"pages/center/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
{{ name }}
onLoad: function (options) {
console.log("page onLoad");
this.setData({
name:'xxzzll'
})
},
Page({
data: {
name:"xzl",
},
})
<block wx:if="{{flag}}">
<view>{{ flag }}</view>
</block>
<view wx:else="{{flag}}">{{ flag}}</view>
<view wx:for="{{ list}}" wx:key="index">
<view>{{item.name}} -- {{index }}</view>
</view>
Page({
data: {
list:[
{
name:"ppp"
},
{
name:"www"
},
{
name:"ccc"
}
],
},
})
wx.redirectTo({
url: '/pages/center/index',
})
wx.showToast({
title: '数据更新完成',
})