2 小程序结构目录&配置文件

 小程序结构目录&配置文件

 

结构目录示例

 

 

配置文件

全局配置文件app.json

      

 

 

 tabbar 位于bottom(top)  --"position":"top"

 
{
  // s所有页面显示在这里
  "pages": [  
    "pages/index/index", 
    "pages/demo01/demo01",
    "pages/img/img",
    "pages/mine/mine", 
    "pages/search/search",
    "pages/demo02/demo02", 
    "pages/logs/logs"
  ],
  "window": {
    //导航栏相关配置
    "navigationBarBackgroundColor": "#0094ff",
    "navigationBarTitleText": "我的应用",
    "navigationBarTextStyle": "black",
    
    // 下拉刷新相关配置
    "enablePullDownRefresh": true,  #是否允许下拉
    "backgroundTextStyle": "dark",  #下拉原点样式
    "backgroundColor": "#f8e71c"  # 下拉背景色
  
  },

  //底部或顶部有 tab 栏可以切换页面(相关配置)
  "tabBar": {
    "list": [
      {
        "pagePath": "pages/index/index",  # 跳转路径
        "text": "首页", #文本
        "iconPath": "icon/_home.png", # 图片
        "selectedIconPath": "icon/home.png" #选中图片路径
      },
      {
        "pagePath": "pages/img/img",
        "text": "图片",
        "iconPath": "icon/_img.png",
        "selectedIconPath": "icon/img.png"
      },
      {
        "pagePath": "pages/mine/mine",
        "text": "我的",
        "iconPath": "icon/_my.png",
        "selectedIconPath": "icon/my.png"
      },
      {
        "pagePath": "pages/search/search",
        "text": "搜索",
        "iconPath": "icon/_search.png",
        "selectedIconPath": "icon/search.png"
      },
      {
        "pagePath": "pages/demo18/demo18",
        "text": "demo18",
        "iconPath": "icon/_search.png",
        "selectedIconPath": "icon/search.png"
      }
    ],
    "color":"#0094ff",  # 文字颜色
    "selectedColor":"#ff9400", # 文字选中颜色
    "backgroundColor":"#ff5533", # 背景颜色
    "position":"top"  # 位置
  },
  "sitemapLocation": "sitemap.json"
}
View Code

 

页面配置文件app.json

开发者可以独⽴定义每个⻚⾯的⼀些属性,如顶部颜⾊、是否允许下拉刷新等等。
⻚⾯的配置只能设置 app.json中部分 window配置项的内容,⻚⾯中配置项会覆盖 app.json的 window中相同的配置项。 
 
{
  "usingComponents": {},
  "navigationBarBackgroundColor": "#0094aa",
  "navigationBarTitleText": "我的应用-demo01"
}
View Code

 

posted @ 2021-11-19 01:16  风hua  阅读(64)  评论(0)    收藏  举报