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"
        }
    ]
}
相关推荐
devlei7 小时前
从源码泄露看AI Agent未来:深度对比Claude Code原生实现与OpenClaw开源方案
android·前端·后端
Jagger_8 小时前
周末和AI肝了两天,终于知道:为什么要把AI当做实习生
前端
weixin_456164838 小时前
vue3 子组件向父组件传参
前端·vue.js
沉鱼.448 小时前
第十二届题目
java·前端·算法
Setsuna_F_Seiei8 小时前
CocosCreator 游戏开发 - 多维度状态机架构设计与实现
前端·cocos creator·游戏开发
Bigger8 小时前
CodeWalkers:让 AI 助手化身桌面宠物,陪你敲代码的赛博伙伴!
前端·app·ai编程
cyclv9 小时前
无网络地图展示轨迹,地图瓦片下载,绘制管线
前端·javascript
土豆125010 小时前
Tauri 入门与实践:用 Rust 构建你的下一个桌面应用
前端·rust
小陈工11 小时前
2026年4月2日技术资讯洞察:数据库融合革命、端侧AI突破与脑机接口产业化
开发语言·前端·数据库·人工智能·python·安全
IT_陈寒12 小时前
Vue的这个响应式问题,坑了我整整两小时
前端·人工智能·后端