@click.native="$router.push({ name: 'paymentRecord', query: { opid } })"
:src="require('@/assets/icon/common/search-white.png')"
computed: {
opid() {
return this.$route.query.opid || '';
},
}
- 定义路由,开发环境不使用懒加载(热更新太慢),生产环境使用懒加载
import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
let customImport;
// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
if (process.env.NODE_ENV === 'development') {
customImport = file => require(`@/pages/${file}.vue`).default;
} else {
customImport = file => () => import(`@/pages/${file}.vue`).then(m => m.default);
}
export default new Router({
routes: [
// index
{
path: '/views/Index',
name: 'index',
component: customImport('views/Index'),
meta: { title: '首页' },
},
// search
{
path: 'views/Search',
name: 'search',
component: customImport('views/Search'),
meta: { title: '查询' },
},
// 所有重定向到index页
{ path: '*', redirect: { name: 'index' } },
],
});
localstorage.setItem()