微信小程序项目中的4种 JSON 配置文件

  1. 项目根目录中的 app.json 配置文件
    1. app.json 是当前小程序的全局配置,包括了小程序的所有页面路径、窗口外观、界面表现、底部 tab 等,如下:

      {
        "pages":[
          "pages/index/index",
          "pages/logs/logs"
        ],
        "window":{
          "backgroundTextStyle":"light",
          "navigationBarBackgroundColor": "#fff",
          "navigationBarTitleText": "Weixin",
          "navigationBarTextStyle":"black"
        },
        "style": "v2",
        "sitemapLocation": "sitemap.json"
      }
      
      
    2. 全局配置中的4个配置项的作用:

      1. pages:用来记录当前小程序所有页面的路径
      2. window:全局定义小程序所有页面的背景色、文字颜色等
      3. style:全局定义小程序组件所使用的样式版本
      4. sitemapLocation:用来指明 sitemap.json 的位置
  2. 项目根目录中的 project.config.json 配置文件
    1. project.config.json 是项目配置文件,用来记录我们对小程序开发工具所做的个性化配置,如下:

      {
        "description": "项目配置文件",
        "packOptions": {
          "ignore": [],
          "include": []
        },
        "setting": {
          "bundle": false,
          "userConfirmedBundleSwitch": false,
          "urlCheck": true,
          "scopeDataCheck": false,
          "coverView": true,
          "es6": true,
          "postcss": true,
          "compileHotReLoad": false,
          "lazyloadPlaceholderEnable": false,
          "preloadBackgroundData": false,
          "minified": true,
          "autoAudits": false,
          "newFeature": false,
          "uglifyFileName": false,
          "uploadWithSourceMap": true,
          "useIsolateContext": true,
          "nodeModules": false,
          "enhance": true,
          "useMultiFrameRuntime": true,
          "useApiHook": true,
          "useApiHostProcess": true,
          "showShadowRootInWxmlPanel": true,
          "packNpmManually": false,
          "enableEngineNative": false,
          "packNpmRelationList": [],
          "minifyWXSS": true,
          "showES6CompileOption": false,
          "minifyWXML": true,
          "babelSetting": {
            "ignore": [],
            "disablePlugins": [],
            "outputPath": ""
          },
          "condition": false
        },
        "compileType": "miniprogram",
        "libVersion": "2.19.4",
        "appid": "wx0000000000000000",
        "projectname": "miniprogram-92",
        "condition": {},
        "editorSetting": {
          "tabIndent": "insertSpaces",
          "tabSize": 2
        }
      }
      
      
    2. 其中:

      1. setting 中保存了编译相关的配置
      2. projectname 中保存的是项目名称
      3. appid 中保存的是小程序的账号 ID
  3. 项目根目录中的 sitemap.json 配置文件
    1. 微信现已开放小程序内搜索,效果类似于 PC 网页的 SEO。sitemap.json 文件用来配置小程序页面是否允许微信索引
    2. 当开发者允许微信索引时,微信会通过爬虫的形式,为小程序的页面内容建立索引。当用户的搜索关键字和页面的索引匹配成功的时候,小程序的页面将可能展示在搜索结果中
    3. 注意:sitemap 的索引提示是默认开启的,如需要关闭 sitemap 的索引提示,可在小程序项目配置文件 project.config.json 的 setting 中配置字段 checkSiteMap 为 false
  4. 每个页面文件夹中的 .json 配置文件
    1. 小程序中的每一个页面,可以使用 .json 文件来对本页面的窗口外观进行配置,页面中的配置项会覆盖 app.json 的 window 中相同的配置项
json
38 views
Comments
登录后评论
Sign In