1.配置tab

在pages文件夹下新增两个文件夹

uniapp开发的微信小程序新增页面和路由跳转

 

 在pages.json中配置路径:

"pages": [ 
        {
            "path": "pages/index/index",
            "style": {
                "navigationBarTitleText": "我的"
            }
        },
        {
            "path": "pages/class/class",
            "style": {
                "navigationBarTitleText": "登录"
            }
        },
    ],

 

pages.json文件增加tabBar配置(和pages在同一层级):

// tabBar 配置
    "tabBar": {
        "color": "#7A7E83",
        "selectedColor": "red",
        "borderStyle": "black",
        "backgroundColor": "#ffffff",
        "list": [{
            "pagePath": "pages/index/index",
            "iconPath": "static/logo.png",
            "selectedIconPath": "static/logo.png",
            "text": "登陆"
        }, {
            "pagePath": "pages/class/class",
            "iconPath": "static/logo.png",
            "selectedIconPath": "static/logo.png",
            "text": "我的"
        }]
    },

 

2. uniapp中的路由管理

pages.json里配置每个路由页面的路径及页面样式,不支持 Vue Router

所以新增的页面需要现在pages.json中配置相应路径才可以访问

 

3. uniapp中的路由跳转

配置了tab的页面可以直接通过点击tab项来跳转

非tab页面的路由跳转有两种方式,详见文档:https://uniapp.dcloud.io/frame?id=%e8%b7%af%e7%94%b1%e8%b7%b3%e8%bd%ac

uni-app 有两种页面路由跳转方式:使用navigator组件跳转、调用API跳转

类似于vue中的<router to="url"></router>

和this.router.push(url: "")

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2021-12-19
  • 2021-11-06
  • 2022-01-04
  • 2021-06-18
  • 2021-12-22
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2021-05-25
  • 2022-01-03
  • 2021-11-23
相关资源
相似解决方案