chore: vue-router-next api change

This commit is contained in:
chenjiahan
2020-04-19 14:33:56 +08:00
parent 722aacb97f
commit 7551238d37
5 changed files with 20 additions and 31 deletions
+8 -1
View File
@@ -16,6 +16,7 @@
import VanDoc from './components';
import { config, packageVersion } from 'site-desktop-shared';
import { setLang } from '../common/locales';
import { scrollToAnchor } from './utils';
export default {
components: {
@@ -39,7 +40,7 @@ export default {
langConfigs() {
const { locales = {} } = config.site;
return Object.keys(locales).map(key => ({
return Object.keys(locales).map((key) => ({
lang: key,
label: locales[key].langLabel || '',
}));
@@ -75,6 +76,12 @@ export default {
this.setTitle();
},
mounted() {
if (this.$route.hash) {
scrollToAnchor(this.$route.hash);
}
},
methods: {
setTitle() {
let { title } = this.config;
+1 -14
View File
@@ -1,18 +1,5 @@
import { createApp } from 'vue';
import App from './App';
import VueRouter from 'vue-router';
import { router } from './router';
import { scrollToAnchor } from './utils';
const app = createApp({
el: '#app',
mounted() {
if (this.$route.hash) {
scrollToAnchor(this.$route.hash);
}
},
render: (h) => h(App),
router,
});
app.use(VueRouter);
createApp(App).use(router).mount('#app');
+3 -3
View File
@@ -1,5 +1,5 @@
import { nextTick } from 'vue';
import VueRouter from 'vue-router';
import { createRouter, createWebHashHistory } from 'vue-router';
import { isMobile, decamelize } from '../common';
import { config, documents } from 'site-desktop-shared';
import { getLang, setDefaultLang } from '../common/locales';
@@ -98,8 +98,8 @@ function getRoutes() {
return routes;
}
export const router = new VueRouter({
mode: 'hash',
export const router = createRouter({
history: createWebHashHistory(),
routes: getRoutes(),
scrollBehavior(to) {
if (to.hash) {