logo头像
Snippet 博客主题

Vue使用问题

页面参数传递

params

通过route.params 获取参数

1
console.log(this.$route.params.uuid)

一、 在Router 中定义
:uuid 方式定义params

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
export const constantRouterMap = [
{ path: '/404', component: () => import('@/views/404'), hidden: true },

{
path: '/',
component: Layout,
redirect: '/index',
name: 'Index',
hidden: true,
children: [{
path: 'index',
component: () => import('@/views/index')
}]
},
{
path: '/notify/:uuid/:jsession',
component: Layout,
name: 'Notify',
hidden: true,
children: [{
path: '',
component: () => import('@/views/notify/notify')
}]
},
{ path: '*', redirect: '/404', hidden: true }
]

二、 在页面中获取参数

1
console.log(this.$route.params.uuid)

query

通过query 获取参数

1
console.log(this.$route.query)

一、 添加参数

无须定义 router
只要在url 添加 ?uuid=XXX&jsession=XXX

二、 获取参数

1
console.log(this.$route.query)

国际化

参考

js 使用

1
this.features[0].name = this.paymentDay + this.$t('route._day_video_history')

html 使用

1
<span>{{ $t("route.LEARN_MORE") }} </span>

js 缓存问题

在移动端 webview 会缓存 js ,js 文件名一样会使用缓存js

解决方案

发版 修改 version

config.js 中添加 version

1
2

version: new Date().getTime()

在 build/webpack.prod.conf.js

修改前

1
2
3
4
5
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash:8].js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js')
},

修改后

1
2
3
4
5
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash:8]' + config.build.version + '.js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash:8]' + config.build.version + '.js')
},
支付宝打赏 微信打赏

打赏