我正在使用vue.js和webpack为我的朋友开发主页。但是他想保留一些使用javascript和jquery(cdn)的旧页面。 我可以在vue-router中做一些配置来做这样的事情吗?
initialiseWeight(){
this.storage.ready().then(() => {
return this.storage.get('weightunit');
})
.then(retrievedUnit => {
if (retrievedUnit) {
this.data.weightunit = retrievedUnit;
} else {
this.data.weightunit = 'kg';
this.storage.set('weightunit', this.data.weightunit);
}
})
.catch(e => console.error('ERROR: could not read Storage Weight, error:', e));
this.storage.ready().then(() => {
return this.storage.get('realWeight');
})
.then(retrievedRealWeight => {
if (retrievedRealWeight && retrievedRealWeight!== "0" ) {
this.data.realWeight = parseInt(retrievedRealWeight, 10);
this.storage.get('userWeight').then((value) => {
this.data.userWeight = parseInt(value, 10);
});
if ( (this.data.realWeight * 1.02 < this.data.userWeight) && (!this.data.isWetsuit) ) {
this.data.userWeight = this.data.realWeight;
this.storage.set('userWeight', this.data.userWeight);
}
} else {
this.data.realWeight = 70;
this.data.userWeight = 70;
this.storage.set('realWeight', this.data.realWeight);
this.storage.set('userWeight', this.data.userWeight);
}
})
.catch(e => console.error('ERROR: could not read Storage Weight, error:', e));
}
this.initialiseWeight();
答案 0 :(得分:3)
您只需使用Vue路由器的Redirect and Alias:
“在路由配置中也完成了重定向。要从/ a重定向到/ b:”
const router = new VueRouter({
routes: [
{ path: '/a', redirect: '/b' }
]
})