uni-app入门(pages.json配置项列表)

一、tabBar

如果应用是一个多 tab 应用,可以通过 tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页。

注意:

属性说明:

属性 类型 必填 默认值 描述 color HexColor 是 tab 上的文字默认颜色 selectedColor HexColor 是 tab 上的文字选中时的颜色 backgroundColor HexColor 是 tab 的背景色 borderStyle String 否 black tabbar 上边框的颜色,可选值 black/white list Array 是 tab 的列表,详见 list 属性说明,最少2个、最多5个 tab position String 否 可选值 bottom、top fontSize String 否 10px 文字默认大小 iconWidth String 否 24px 图标默认宽度(高度等比例缩放) spacing String 否 3px 图标和文字的间距 height String 否 50px tabBar 默认高度

list 接收一个数组,数组中的每个项都是一个对象,其属性值如下:

属性 类型 必填 描述 pagePath String 是 页面路径,必须在 pages 中先定义 text String 是 tab 上按钮文字,在 App 和 H5 平台为非必填。例如中间可放一个没有文字的+号图标 iconPath String 否 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 selectedIconPath String 否 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效

代码示例

"tabBar": {
          
   
    "color": "#7A7E83",
    "selectedColor": "#3cc51f",
    "borderStyle": "black",
    "backgroundColor": "#ffffff",
    "list": [{
          
   
        "pagePath": "pages/component/index",
        "iconPath": "static/image/icon_component.png",
        "selectedIconPath": "static/image/icon_component_HL.png",
        "text": "组件"
    }, {
          
   
        "pagePath": "pages/API/index",
        "iconPath": "static/image/icon_API.png",
        "selectedIconPath": "static/image/icon_API_HL.png",
        "text": "接口"
    }]
}

二、condition

属性说明:

属性 类型 必填 描述 current Number 是 当前激活的模式,list节点的索引值 list Array 是 启动模式列表

list说明:

属性 类型 必填 描述 name String 是 启动模式名称 path String 是 启动页面路径 query String 否 启动参数,可在页面的 onLoad 函数里获得
"condition": {
          
    //模式配置,仅开发期间生效
    "current": 0, //当前激活的模式(list 的索引项)
    "list": [{
          
   
            "name": "swiper", //模式名称
            "path": "pages/component/swiper/swiper", //启动页面,必选
            "query": "interval=4000&autoplay=false" //启动参数,在页面的onLoad函数里面得到。
        },
        {
          
   
            "name": "test",
            "path": "pages/component/switch/switch"
        }
    ]
}
经验分享 程序员 微信小程序 职场和发展