• 小程序制作(超详解!!!)第十六节 小程序的基本架构


    1.题目描述

    创建一个包含:首页、教学、科研、资讯和关于我们5个标签的小程序,每个标签都有对应的页面、图标和标签文字,点击某个标签将切换到对应的页面,同时该标签的图标和文字颜色都会发生变化页面的标题也发生相应的变化,而其他标签则变为非选中状态。

    2.app.json

    1. {
    2. "pages": [
    3. "pages/shouye/shouye",
    4. "pages/beibeiting/beibeiting",
    5. "pages/beibeile/beibeile",
    6. "pages/shequ/shequ",
    7. "pages/wode/wode"
    8. ],
    9. "window": {
    10. "navigationBarBackgroundColor": "#fff",
    11. "navigationBarTitleText": "财小贝",
    12. "navigationBarTextStyle": "black"
    13. },
    14. "tabBar": {
    15. "color":"#000",
    16. "selectedColor": "#00f",
    17. "list":[
    18. {
    19. "pagePath": "pages/shouye/shouye",
    20. "text":"贝贝看",
    21. "iconPath": "/images/贝贝看-关.png",
    22. "selectedIconPath": "/images/贝贝看-开.png"
    23. },
    24. {
    25. "pagePath": "pages/beibeiting/beibeiting",
    26. "text":"贝贝听",
    27. "iconPath": "/images/贝贝听-关.png",
    28. "selectedIconPath": "/images/贝贝听-开.png"
    29. },
    30. {
    31. "pagePath": "pages/beibeile/beibeile",
    32. "text":"贝贝乐",
    33. "iconPath": "/images/贝贝乐-关.png",
    34. "selectedIconPath": "/images/贝贝乐-开.png"
    35. },
    36. {
    37. "pagePath": "pages/shequ/shequ",
    38. "text":"社区",
    39. "iconPath": "/images/贝贝社区-关.png",
    40. "selectedIconPath": "/images/贝贝社区-开.png"
    41. },
    42. {
    43. "pagePath": "pages/wode/wode",
    44. "text":"我的",
    45. "iconPath": "/images/贝贝我的-关.png",
    46. "selectedIconPath": "/images/贝贝我的-开.png"
    47. }
    48. ]
    49. },
    50. "sitemapLocation": "sitemap.json"
    51. }

    3.shouye.json

    1. {
    2. "navigationBarBackgroundColor": "#ff0000",
    3. "navigationBarTextStyle":"white",
    4. "navigationBarTitleText": "贝贝看"
    5. }

    4.目录

    images中的照片要自己提前存。

    5.总结

    1.全局配置

    app.json文件属性

    属性类型必填描述
    pagesstring[]页面路径列表
    windowObject全局的默认窗口表现
    tabBarObject底部tab栏的表现
    networkTimeoutObject网络超时时间
    debugboolean是否开启debug模式,默认关闭
    permissiomObject小程序接口权限相关设置

    Pages配置

    pages用于指定小程序由哪些页面组成,每一项都对应一个页面路径(含文件名)信息。文件名不需要写文件后缀,框架会自动去寻找对应位置的.json,.js,.wxml,.wxss四个文件进行处理。数组的第一项代表小程序的初始页面(首页)。小程序中新增/减少页面,都需要对pages数组进行修改。

    Window配置

    属性类型描述

    navigationBarBackgroundColor

    HexColor导航栏背景颜色

    navigationBarTextStyle

    string导航栏标题颜色

    navigationBarTitleText

    string导航栏标题文字内容
    backgroundColorHexColor窗口的背景色
    backgroundTextStylestring下拉loading的样式,仅支持dark/light
    pageOrientationstring屏幕旋转设置,支持auto/portrait/landscape

    tabBar配置

    属性类型描述
    colorHexColortab上的文字的默认颜色
    selectedColorHexColortab上选中文字的颜色
    backgroundColorHexColortab的背景色
    borderStylestringtabbar上边框的颜色,仅支持black/white
    listArraytab列表,最少2个、最多5个tab
    positionstringtabBar的位置,仅支持bottom/top

    list配置

    属性类型必填说明
    pagePathstring页面路径,必须在pages中先定义
    textstringtab上按钮文字
    iconPathstring图片路径,icon大小限制为40kb,建议尺寸为81px*81px,不支持网络图片
    selectedIdconPathstring选中时的图片路径

    2.页面配置

    每一个小程序页面也可以使用同名.json文件来对本页面的窗口表现进行配置,页面中配置项会覆盖app.json的window中相同的配置项。

  • 相关阅读:
    数据结构与算法分析之并查集
    画图实战-Python实现某产品全年销量数据多种样式可视化
    既要便捷、安全+智能,也要颜值,萤石发布北斗星人脸锁DL30F和极光人脸视频锁Y3000FV
    计算机网络原理 谢希仁(第8版)第三章习题答案
    [Mongodb 5.0]比较运算符
    flowable
    Leetcode刷题98. 验证二叉搜索树
    uniapp开启微信支付、支付宝支付 + Android Studio离线打包APK文件 (前端部分)
    【飞桨Paddle】RTSP视频流和PP-Human实时行人分析
    jieba
  • 原文地址:https://blog.csdn.net/2201_76115387/article/details/134296637