自在天 每日分享

每日分享

小程序页面配置文件

小程序-页面配置

每一个小程序页面也可以使用 .json 文件来对本页面的窗口表现进行配置。

页面中配置项在当前页面会覆盖 app.json 的 window 中相同的配置项。

文件内容为一个 JSON 对象,有以下属性:

配置项

属性类型默认值描述
navigationBarBackgroundColorHexColor#000000导航栏背景颜色,如 #000000
navigationBarTextStylestringwhite导航栏标题颜色,仅支持 black / white
navigationBarTitleTextstring
导航栏标题文字内容
navigationStylestringdefault导航栏样式,仅支持以下值:
default 默认样式
custom 自定义导航栏,只保留右上角胶囊按钮。参见注 1。
backgroundColorHexColor#ffffff窗口的背景色
backgroundTextStylestringdark下拉 loading 的样式,仅支持 dark / light
backgroundColorTopstring#ffffff顶部窗口的背景色,仅 iOS 支持
backgroundColorBottomstring#ffffff底部窗口的背景色,仅 iOS 支持
enablePullDownRefreshbooleanfalse是否开启当前页面下拉刷新。
详见 Page.onPullDownRefresh
onReachBottomDistancenumber50页面上拉触底事件触发时距页面底部距离,单位为px。
详见 Page.onReachBottom
pageOrientationstringportrait屏幕旋转设置,支持 auto / portrait / landscape
详见 响应显示区域变化
disableScrollbooleanfalse设置为 true 则页面整体不能上下滚动。
只在页面配置中有效,无法在 app.json 中设置
usingComponentsObject页面自定义组件配置
initialRenderingCachestring
页面初始渲染缓存配置
stylestringdefault启用新版的组件样式
singlePageObject单页模式相关配置

页面配置中只能设置 app.json 中 window 对应的配置项,以决定本页面的窗口表现,

所以无需写 window 这个属性。

  • 注 1:关于navigationStyle

    • iOS/Android 客户端 7.0.0 以下版本,

      navigationStyle 只在 app.json 中生效。

    • iOS/Android 客户端 6.7.2 版本开始,

      navigationStyle: custom 对 web-view 组件无效

    • 开启 custom 后,低版本客户端需要做好兼容。

      发者工具基础库版本切到 1.7.0(不代表最低版本,只供调试用)可方便切到旧视觉

    • Windows 客户端 3.0 及以上版本,

      为了给用户提供更符合桌面软件的使用体验,

      统一了小程序窗口的导航栏,navigationStyle: custom 不再生效

singlePage

基础库 2.11.3 及以上版本支持,目前分享到朋友圈 (Beta) 后打开会进入单页模式

单页模式相关配置

属性类型必填默认值描述
navigationBarFitString默认自动调整,若原页面是自定义导航栏,则为 float,否则为 squeezed导航栏与页面的相交状态,值为 float 时表示导航栏浮在页面上,与页面相交;值为 squeezed 时表示页面被导航栏挤压,与页面不相交

配置示例

{
  "navigationBarBackgroundColor": "#ffffff",
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "微信接口功能演示",
  "backgroundColor": "#eeeeee",
  "backgroundTextStyle": "light"}


  • 评论列表:
  •  亚马逊跨境电商运营宝典
     发布于 2021-07-14 08:08:16  回复该评论
  • 赞一个。。。。。。
    •  CpjJwWHV
       发布于 2023-11-14 02:12:24  回复该评论
    • [face_01] [face_02] [face_03] [face_04] [face_05] [face_06] [face_07] [face_08] [face_09] [face_10] [face_11] [face_12] [face_13] [face_14] [face_15] [face_16] [face_17] [face_18] [face_19] [face_20] [face_21] [face_22] [face_23] [face_24] [face_26] [face_26] [face_27] [face_28] [face_29] [face_30] [face_31] [face_32] [face_33] [face_34] [face_35] [face_36]
      •  tsSLAueP
         发布于 2024-08-19 12:19:38  回复该评论
      • [face_01] [face_02] [face_03] [face_04] [face_05] [face_06] [face_07] [face_08] [face_09] [face_10] [face_11] [face_12] [face_13] [face_14] [face_15] [face_16] [face_17] [face_18] [face_19] [face_20] [face_21] [face_22] [face_23] [face_24] [face_26] [face_26] [face_27] [face_28] [face_29] [face_30] [face_31] [face_32] [face_33] [face_34] [face_35] [face_36]

发表评论:

Powered By Z-BlogPHP 1.7.3

Copyright qq8652.cn.自在天博客 版权所有. ICP备案:京ICP备20021747号

京公网安备 11010602007213号


..