app.json文件详解

app.json文件的详解

1. 属性说明

  1. pages属性说明
    1. 页面配置
      1. 项目文件构成
        在这里插入图片描述
      2. 示例
        1. 代码
          {
            "pages": [
              "pages/index/index",
              "pages/logs/logs"
            ],
            "window": {
              "backgroundTextStyle": "light",
              "navigationBarBackgroundColor": "#fff",
              "navigationBarTitleText": "ccblogs",
              "navigationBarTextStyle": "black"
            },
            "style": "v2",
            "sitemapLocation": "sitemap.json"
          }
          
  2. window属性说明
    1. navigationBarTitleText:导航栏标题文字内容
    2. navigationBarBackgroundColor:导航栏背景颜色
    3. navigationBarTextStyle:导航栏标题颜色
    4. 示例
      1. 代码
        {
          "pages": [
            "pages/index/index",
            "pages/logs/logs"
          ],
          "window": {
            "backgroundTextStyle": "light",
            "navigationBarBackgroundColor": "#000",
            "navigationBarTitleText": "ccblogs",
            "navigationBarTextStyle": "white"
          },
          "style": "v2",
          "sitemapLocation": "sitemap.json"
        }
        
      2. 效果
        在这里插入图片描述
    5. enablePullDownRefresh:是否开启当前页面下拉刷新。
    6. backgroundColor:设置背景色
    7. backgroundTextStyle:下拉 loading 的样式,仅支持 dark / light
    8. 示例
      1. 代码
        {
          "pages": [
            "pages/index/index",
            "pages/logs/logs"
          ],
          "window": {
            "backgroundTextStyle": "dark",
            "navigationBarBackgroundColor": "#000",
            "navigationBarTitleText": "ccblogs",
            "navigationBarTextStyle": "white",
            "enablePullDownRefresh": true,
            "backgroundColor": "#ddd"
          },
          "style": "v2",
          "sitemapLocation": "sitemap.json"
        }
        
      2. 效果
        在这里插入图片描述
  3. 单页面修改
    1. 单页面修改内容需要在单页面的json中修改,比如修改日志界面需要在logs.json文件中修改,属性和全局app.json一致,index.json不需要设置,默认使用logs.json
    2. 示例
      1. 代码
        // logs.json
        {
          "navigationBarTitleText": "查看启动日志",
          "usingComponents": {}
        }
        
      2. 效果
        在这里插入图片描述
      3. 代码
        // index.json
        {
          "usingComponents": {}
        }
        
  4. 底部触摸栏
    1. list:Tabbar的项的数组,按照规范,至少要有2个Tabbar项
    2. selectedColor:tab 上的文字选中时的颜色
    3. borderStyle:tabBar上边框的颜色, 仅支持 black/white
    4. pagePath:跳转页面的路径
    5. text:Tabbar项的标题
    6. iconPath:Tabbar项的icon图片路径,建议使用绝对路径,相对路径要相对于组件所在目录的。
    7. selectedIconPath:Tabbar项选中时的icon,建议使用绝对路径,相对路径要相对于组件所在目录的。
    8. 示例
      1. 代码
        {
          "pages": [
            "pages/index/index",
            "pages/logs/logs"
          ],
          "window": {
            "backgroundTextStyle": "dark",
            "navigationBarBackgroundColor": "#000",
            "navigationBarTitleText": "ccblogs",
            "navigationBarTextStyle": "white",
            "enablePullDownRefresh": true,
            "backgroundColor": "#ddd"
          },
          "style": "v2",
          "sitemapLocation": "sitemap.json",
          "tabBar": {
            "selectedColor": "#1AAD19",
            "borderStyle": "black",
            "list": [{
              "pagePath": "pages/index/index",
              "borderStyle": "black",
              "text": "首页",
              "iconPath": "images/index.png",
              "selectedIconPath": "images/index_selected.png"
            },
            {
              "pagePath": "pages/logs/logs",
              "text": "日志",
              "iconPath": "images/log.png",
              "selectedIconPath": "images/log_selected.png"
            }]
          }
        }
        
      2. 效果
        在这里插入图片描述
        在这里插入图片描述
  5. 网络请求的超时时间,单位:毫秒
    1. request:普通 HTTPS 请求
    2. connectSocket:WebSocket 通信
    3. uploadFile:上传文件
    4. downloadFile:下载文件
    5. debug:设置为true,可以在调试器控制台打印出程序调试信息
    6. 示例
      1. 代码
        {
          "pages": [
            "pages/index/index",
            "pages/logs/logs"
          ],
          "window": {
            "backgroundTextStyle": "dark",
            "navigationBarBackgroundColor": "#000",
            "navigationBarTitleText": "ccblogs",
            "navigationBarTextStyle": "white",
            "enablePullDownRefresh": true,
            "backgroundColor": "#ddd"
          },
          "style": "v2",
          "sitemapLocation": "sitemap.json",
          "tabBar": {
            "selectedColor": "#1AAD19",
            "borderStyle": "black",
            "list": [{
              "pagePath": "pages/index/index",
              "borderStyle": "black",
              "text": "首页",
              "iconPath": "images/index.png",
              "selectedIconPath": "images/index_selected.png"
            },
            {
              "pagePath": "pages/logs/logs",
              "text": "日志",
              "iconPath": "images/log.png",
              "selectedIconPath": "images/log_selected.png"
            }]
          },
          "networkTimeout": {
            "request": 20000,
            "connectSocket": 20000,
            "uploadFile": 20000,
            "downloadFile": 20000
          },
          "debug": true
        }
        
      2. 效果
        在这里插入图片描述
发布了31 篇原创文章 · 获赞 3 · 访问量 2294

猜你喜欢

转载自blog.csdn.net/ccblogs/article/details/104722843