mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: vue-router-next api change
This commit is contained in:
parent
722aacb97f
commit
7551238d37
@ -16,6 +16,7 @@
|
|||||||
import VanDoc from './components';
|
import VanDoc from './components';
|
||||||
import { config, packageVersion } from 'site-desktop-shared';
|
import { config, packageVersion } from 'site-desktop-shared';
|
||||||
import { setLang } from '../common/locales';
|
import { setLang } from '../common/locales';
|
||||||
|
import { scrollToAnchor } from './utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -39,7 +40,7 @@ export default {
|
|||||||
|
|
||||||
langConfigs() {
|
langConfigs() {
|
||||||
const { locales = {} } = config.site;
|
const { locales = {} } = config.site;
|
||||||
return Object.keys(locales).map(key => ({
|
return Object.keys(locales).map((key) => ({
|
||||||
lang: key,
|
lang: key,
|
||||||
label: locales[key].langLabel || '',
|
label: locales[key].langLabel || '',
|
||||||
}));
|
}));
|
||||||
@ -75,6 +76,12 @@ export default {
|
|||||||
this.setTitle();
|
this.setTitle();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
if (this.$route.hash) {
|
||||||
|
scrollToAnchor(this.$route.hash);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
setTitle() {
|
setTitle() {
|
||||||
let { title } = this.config;
|
let { title } = this.config;
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import VueRouter from 'vue-router';
|
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
import { scrollToAnchor } from './utils';
|
|
||||||
|
|
||||||
const app = createApp({
|
createApp(App).use(router).mount('#app');
|
||||||
el: '#app',
|
|
||||||
mounted() {
|
|
||||||
if (this.$route.hash) {
|
|
||||||
scrollToAnchor(this.$route.hash);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render: (h) => h(App),
|
|
||||||
router,
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(VueRouter);
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||||
import { isMobile, decamelize } from '../common';
|
import { isMobile, decamelize } from '../common';
|
||||||
import { config, documents } from 'site-desktop-shared';
|
import { config, documents } from 'site-desktop-shared';
|
||||||
import { getLang, setDefaultLang } from '../common/locales';
|
import { getLang, setDefaultLang } from '../common/locales';
|
||||||
@ -98,8 +98,8 @@ function getRoutes() {
|
|||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const router = new VueRouter({
|
export const router = createRouter({
|
||||||
mode: 'hash',
|
history: createWebHashHistory(),
|
||||||
routes: getRoutes(),
|
routes: getRoutes(),
|
||||||
scrollBehavior(to) {
|
scrollBehavior(to) {
|
||||||
if (to.hash) {
|
if (to.hash) {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
|
||||||
import DemoBlock from './components/DemoBlock';
|
import DemoBlock from './components/DemoBlock';
|
||||||
import DemoSection from './components/DemoSection';
|
import DemoSection from './components/DemoSection';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
@ -7,13 +6,9 @@ import App from './App';
|
|||||||
import '@vant/touch-emulator';
|
import '@vant/touch-emulator';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const app = createApp({
|
createApp(App)
|
||||||
render: (h) => h(App),
|
.use(router)
|
||||||
router,
|
.component(DemoBlock.name, DemoBlock)
|
||||||
});
|
.component(DemoSection.name, DemoSection)
|
||||||
|
.mount('#app');
|
||||||
app.use(VueRouter);
|
|
||||||
app.component(DemoBlock.name, DemoBlock);
|
|
||||||
app.component(DemoSection.name, DemoSection);
|
|
||||||
app.mount('#app');
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||||
import DemoHome from './components/DemoHome';
|
import DemoHome from './components/DemoHome';
|
||||||
import { decamelize } from '../common';
|
import { decamelize } from '../common';
|
||||||
import { demos, config } from 'site-mobile-shared';
|
import { demos, config } from 'site-mobile-shared';
|
||||||
@ -81,8 +81,8 @@ function getRoutes() {
|
|||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const router = new VueRouter({
|
export const router = createRouter({
|
||||||
mode: 'hash',
|
mode: createWebHashHistory(),
|
||||||
routes: getRoutes(),
|
routes: getRoutes(),
|
||||||
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
|
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user