小程序:详解app.json文件、绑定方法、页面跳转

{
  "pages":[
    "pages/news/news",//在pages下添加news文件夹以及news文件夹下的一套页面
    "pages/news/child/child",//在news下添加child文件夹以及child文件夹下的一套页面
     "pages/news/child",//在news下添加child的一套页面
    "pages/index/index",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#ccc",//导航栏的颜色
    "navigationBarTitleText": "小程序aaa",//导航栏的文字
    "navigationBarTextStyle":"black",//导航栏的文字颜色
     "enablePullDownRefresh":true//全局添加下拉刷新
  },
   "tabBar": {//底部导航栏:最少两个最多五个
     "position":"bottom",//底部导航栏位置,top在上面显示
     "list": [
       {
       "iconPath": "iconPath",//图标、路径
       "selectedIconPath": "iconPath",//选中后的图标、路径
       "pagePath": "pages/news/news",//文件路径
       "text": "新页面"//文字
       },
       {
       "iconPath": "iconPath",//图标、路径
       "selectedIconPath": "iconPath",//选中后的图标、路径
       "pagePath": "pages/index/index",
       "text": "首页"
       },
       {
       "iconPath": "iconPath",//图标、路径
       "selectedIconPath": "iconPath",//选中后的图标、路径
       "pagePath": "pages/logs/logs",
       "text": "日志"
       }
     ]
   },
}

详细信息可以看文档:微信小程序app.json页面的官方配置文档

2、绑定事件:bindtap

<button bindtap='aaa'>按钮</button>
aaa:(e)=>{
  console.log(e);
  wx.navigateTo({//跳转页面方法
    //路径在这里
  });
},

3、跳转页面方法:wx.navigateTo({文件路径(例如:../news/news)});

猜你喜欢

转载自www.cnblogs.com/xinchenhui/p/10409880.html