mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(cli): vue global api change
This commit is contained in:
parent
9b3b1e896c
commit
e44d3955fc
@ -1,19 +1,18 @@
|
||||
import Vue from 'vue';
|
||||
import { createApp } from 'vue';
|
||||
import App from './App';
|
||||
import VueRouter from 'vue-router';
|
||||
import { router } from './router';
|
||||
import { scrollToAnchor } from './utils';
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Vue.config.productionTip = false;
|
||||
}
|
||||
|
||||
new Vue({
|
||||
const app = createApp({
|
||||
el: '#app',
|
||||
mounted() {
|
||||
if (this.$route.hash) {
|
||||
scrollToAnchor(this.$route.hash);
|
||||
}
|
||||
},
|
||||
render: h => h(App),
|
||||
render: (h) => h(App),
|
||||
router,
|
||||
});
|
||||
|
||||
app.use(VueRouter);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Vue from 'vue';
|
||||
import { nextTick } from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import { isMobile, decamelize } from '../common';
|
||||
import { config, documents } from 'site-desktop-shared';
|
||||
@ -48,7 +48,7 @@ function getRoutes() {
|
||||
if (locales) {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||
redirect: (route) => `/${getLangFromRoute(route)}/`,
|
||||
});
|
||||
} else {
|
||||
routes.push({
|
||||
@ -66,7 +66,7 @@ function getRoutes() {
|
||||
});
|
||||
}
|
||||
|
||||
names.forEach(name => {
|
||||
names.forEach((name) => {
|
||||
const { component, lang } = parseName(name);
|
||||
|
||||
if (component === 'home') {
|
||||
@ -98,8 +98,6 @@ function getRoutes() {
|
||||
return routes;
|
||||
}
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
export const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes: getRoutes(),
|
||||
@ -113,7 +111,7 @@ export const router = new VueRouter({
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
Vue.nextTick(() => window.syncPath());
|
||||
nextTick(() => window.syncPath());
|
||||
});
|
||||
|
||||
window.vueRouter = router;
|
||||
|
@ -1,21 +1,19 @@
|
||||
import Vue from 'vue';
|
||||
import { createApp } from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import DemoBlock from './components/DemoBlock';
|
||||
import DemoSection from './components/DemoSection';
|
||||
import { router } from './router';
|
||||
import App from './App';
|
||||
import '@vant/touch-emulator';
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Vue.config.productionTip = false;
|
||||
}
|
||||
|
||||
Vue.component(DemoBlock.name, DemoBlock);
|
||||
Vue.component(DemoSection.name, DemoSection);
|
||||
|
||||
setTimeout(() => {
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(App),
|
||||
const app = createApp({
|
||||
render: (h) => h(App),
|
||||
router,
|
||||
});
|
||||
|
||||
app.use(VueRouter);
|
||||
app.component(DemoBlock.name, DemoBlock);
|
||||
app.component(DemoSection.name, DemoSection);
|
||||
app.mount('#app');
|
||||
}, 0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Vue from 'vue';
|
||||
import { nextTick } from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import DemoHome from './components/DemoHome';
|
||||
import { decamelize } from '../common';
|
||||
@ -29,10 +29,10 @@ function getRoutes() {
|
||||
if (langs.length) {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||
redirect: (route) => `/${getLangFromRoute(route)}/`,
|
||||
});
|
||||
|
||||
langs.forEach(lang => {
|
||||
langs.forEach((lang) => {
|
||||
routes.push({
|
||||
path: `/${lang}`,
|
||||
component: DemoHome,
|
||||
@ -51,11 +51,11 @@ function getRoutes() {
|
||||
});
|
||||
}
|
||||
|
||||
names.forEach(name => {
|
||||
names.forEach((name) => {
|
||||
const component = decamelize(name);
|
||||
|
||||
if (langs.length) {
|
||||
langs.forEach(lang => {
|
||||
langs.forEach((lang) => {
|
||||
routes.push({
|
||||
name: `${lang}/${component}`,
|
||||
path: `/${lang}/${component}`,
|
||||
@ -81,8 +81,6 @@ function getRoutes() {
|
||||
return routes;
|
||||
}
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
export const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes: getRoutes(),
|
||||
@ -91,7 +89,7 @@ export const router = new VueRouter({
|
||||
|
||||
router.afterEach(() => {
|
||||
if (!router.currentRoute.redirectedFrom) {
|
||||
Vue.nextTick(window.syncPath);
|
||||
nextTick(window.syncPath);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user