我是靠谱客的博主 火星上红牛,这篇文章主要介绍vant tabbar底部导航的使用,现在分享给大家,希望可以做个参考。

新建home.js

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<template> <div id="home"> <div class="tabbar_content"> <router-view></router-view> </div> <!-- vant 标签栏 --> <van-tabbar route active-color="#0f5de5" inactive-color="#444" > <van-tabbar-item v-for="(item, index) in tabbar_items" :key="index" :class="['iconfont', item.iconClass]" replace :to="item.src" >{{item.title}}</van-tabbar-item > </van-tabbar> </div> </template> <script> export default { name: "home", data() { return { active: 0, // tabIndex: 0, // tabbar_items: [ // { title: "首页", iconClass: "iconshouye", src: "/index" }, // { title: "快报", iconClass: "iconicon-test", src: "/scholar" }, // { title: "检索", iconClass: "iconsousuo1", src: "/search" }, // { title: "我的", iconClass: "iconwode", src: "/mine" }, // ], tabbar_items: [ { title: this.$t('tabbar.home'), iconClass: "iconshouye", src: "/index" }, { title: this.$t('tabbar.scholar'), iconClass: "iconicon-test", src: "/scholar" }, { title: this.$t('tabbar.search'), iconClass: "iconsousuo1", src: "/search" }, { title: this.$t('tabbar.mine'), iconClass: "iconwode", src: "/mine" }, ], }; }, methods: {}, }; </script> <style lang="less" scoped> #home { .tabbar_content { padding-bottom: 56px; } .van-tabbar { box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1); } .van-tabbar-item { border-right: 1px solid #eeeeee; font-size: 13px; } .van-tabbar-item:last-child { border: none; } } </style> <!-- home --> <template> <div id="home"> <div class="tabbar_content"> <router-view></router-view> </div> <!-- vant 标签栏 --> <van-tabbar route active-color="#0f5de5" inactive-color="#444" > <van-tabbar-item v-for="(item, index) in tabbar_items" :key="index" :class="['iconfont', item.iconClass]" replace :to="item.src" >{{item.title}}</van-tabbar-item > </van-tabbar> </div> </template> <script> export default { name: "home", data() { return { active: 0, // tabIndex: 0, // tabbar_items: [ // { title: "首页", iconClass: "iconshouye", src: "/index" }, // { title: "快报", iconClass: "iconicon-test", src: "/scholar" }, // { title: "检索", iconClass: "iconsousuo1", src: "/search" }, // { title: "我的", iconClass: "iconwode", src: "/mine" }, // ], tabbar_items: [ { title: this.$t('tabbar.home'), iconClass: "iconshouye", src: "/index" }, { title: this.$t('tabbar.scholar'), iconClass: "iconicon-test", src: "/scholar" }, { title: this.$t('tabbar.search'), iconClass: "iconsousuo1", src: "/search" }, { title: this.$t('tabbar.mine'), iconClass: "iconwode", src: "/mine" }, ], }; }, methods: {}, }; </script> <style lang="less" scoped> #home { .tabbar_content { padding-bottom: 56px; } .van-tabbar { box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1); } .van-tabbar-item { border-right: 1px solid #eeeeee; font-size: 13px; } .van-tabbar-item:last-child { border: none; } } </style>   再router.js写入 import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) const routes = [ { path: '/', redirect: '/index', }, { path: '/home', component: () => import("@/views/home"), name: 'home', meta: { title: '首页' }, children:[ { path: "/index", name: "index", component: () => import("@/views/tabbar/index"), meta: { title: "首页" } }, { path: "/scholar", name: "scholar", component: () => import("@/views/tabbar/scholar"), meta: { title: "快报" } }, { path: "/search", name: "search", component: () => import("@/views/tabbar/search"), meta: { title: "检索" } }, { path: "/mine", name: "mine", component: () => import("@/views/tabbar/mine"), meta: { title: "我的" } } ] }, { path: "/setting", name: "setting", component: () => import("@/views/mine/setting"), meta: { title: "设置" } } ] export default new Router({ mode: 'history',// 访问路径不带井号 routes: routes, // base: __dirname, // linkActiveClass: 'link-active', scrollBehavior (to, from, savedPosition) { // 控制跳到下一页面回到顶端 if (savedPosition) { // 浏览器前进后退触发记录位置 return savedPosition } else { return { x: 0, y: 0 } } } })

最后

以上就是火星上红牛最近收集整理的关于vant tabbar底部导航的使用的全部内容,更多相关vant内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部