vue2.0中的history和hash模式

    1. history模式

import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);

const router = new Router({
	mode: 'history',
	routes: [
		{
			path: '/',
			name: '',
			component: ''
		}
	]
})

    2. hash模式

import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);

const router = new Router({
	mode: 'hash',
	routes: [
		{
			path: '/',
			name: '',
			component: ''
		}
	]
})

vue3.0中的history和hash模式

    1. history模式

import { createRouter, createWebHistory } from 'vue-router';
const routes = [
	{
		path: '/',
		name: '',
		component: ''
	}
];
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});

    2. hash模式

import { createRouter, createWebHashHistory } from "vue-router";
const routes = [
	{
		path: '/',
		name: '',
		component: ''
	}
];
const router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default router;
Logo

前往低代码交流专区

更多推荐