IT廉连看——Uniapp——配置文件pages

IT廉连看------Uniapp------配置文件pages

IT廉连看

本堂课主要为大家介绍pages.json这个配置文件

一、打开官网查看pages.json可以配置哪些属性。

下面边写边讲解

新建一个home页面理解一下这句话。

以下一些页面的通用配置

通用设置里我们可以对导航栏和状态栏进行一些设置

接下来我们更改一下导航栏颜色:

html 复制代码
"navigationBarBackgroundColor": "#282828",                                               alt+鼠标左键可选择颜色

下一步对标题文字进行设置:

html 复制代码
"navigationBarTitleText": "IT",

未更改成功,这是为什么?

接下来更改导航栏文字颜色:

导航栏更改颜色,如今官方只支持修改两种颜色,一种是黑色一种是白色。

二、path和style

path,页面路由

style:其实我们已经使用过了

在这里我们设置的是通用的窗口样式。

如果我们想要每个页面都有不同的样式,那么就根据它的优先级,把这些代码再写入指定的页面。

三、tabbar

1、打开官网查看tabbar介绍

代码示例:

html 复制代码
"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": "接口"
    }]
}

每个配置项代表什么:

html 复制代码
"color": "#7A7E83",                                                             color:颜色
    "selectedColor": "#3cc51f",                                                 selectedColor:选中时的颜色
    "borderStyle": "black",                                                     borderStyle:上边框颜色
    "backgroundColor": "#ffffff",                                               backgroundColor:背景颜色

当我们把页面设置为tabbar页面,我们需要把页面添加近list,list可添加2-5个页面。我们的tabbar需要一些改动。

html 复制代码
"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": "接口"
    }]
复制代码
    我们需要更改页面路径

2、condition

html 复制代码
"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"
        }
    ]
}
相关推荐
一点一木18 分钟前
🚀 2025 年 11 月 GitHub 十大热门项目排行榜 🔥
前端·人工智能·github
白粥19 分钟前
HTML标题标签<h1>到<h6>
前端·html
IT_陈寒30 分钟前
React 18新特性实战:这5个Hook组合让我少写50%状态管理代码
前端·人工智能·后端
HashTang32 分钟前
【AI 编程实战】第 1 篇:TRAE SOLO 模式 10 倍速开发商业级全栈小程序
前端·后端·ai编程
syt_101337 分钟前
grid应用之响应式布局
前端·javascript·css
libolei39 分钟前
chrome浏览器安装axure插件
前端·chrome·chrome插件
黑臂麒麟1 小时前
Electron&OpenHarmony 跨平台实战开发(一):electron-vite 与 Vue3 架构搭建指南
前端·javascript·electron·openharmony
少寒1 小时前
深入理解JavaScript Promise:异步编程的基石
前端·javascript
tecwlcvi3231 小时前
安卓版谷歌地图,Google地图高清版,谷歌地球,谷歌翻译,谷歌(Chrome)浏览器,手机版Edge,浏览器等安卓版浏览器下载
前端·chrome·edge
czlczl200209251 小时前
SpringBoot中web请求路径匹配的两种风格
java·前端·spring boot