diff --git a/package-lock.json b/package-lock.json index 5a029fd..b132d0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,13 +10,15 @@ "dependencies": { "core-js": "^3.8.3", "element-plus": "^2.3.12", - "vue": "^3.2.13" + "vue": "^3.2.13", + "vue-router": "^4.0.3" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", + "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-service": "~5.0.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3" @@ -3051,6 +3053,11 @@ "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true }, + "node_modules/@vue/devtools-api": { + "version": "6.5.0", + "resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz", + "integrity": "sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==" + }, "node_modules/@vue/reactivity": { "version": "3.3.4", "resolved": "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.3.4.tgz", @@ -10600,6 +10607,17 @@ "node": ">=8" } }, + "node_modules/vue-router": { + "version": "4.2.4", + "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.2.4.tgz", + "integrity": "sha512-9PISkmaCO02OzPVOMq2w82ilty6+xJmQrarYZDkjZBfl4RvYAlt4PKnEX21oW4KTtWfa9OuO/b3qk1Od3AEdCQ==", + "dependencies": { + "@vue/devtools-api": "^6.5.0" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, "node_modules/vue-style-loader": { "version": "4.1.3", "resolved": "https://registry.npmmirror.com/vue-style-loader/-/vue-style-loader-4.1.3.tgz", diff --git a/package.json b/package.json index cd63885..4ff6d79 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,6 @@ "name": "vue3_element_demo1", "version": "0.1.0", "private": true, - "devDependencies": { - "@babel/core": "^7.12.16", - "@babel/eslint-parser": "^7.12.16", - "@vue/cli-plugin-babel": "~5.0.0", - "@vue/cli-plugin-eslint": "~5.0.0", - "@vue/cli-service": "~5.0.0", - "eslint": "^7.32.0", - "eslint-plugin-vue": "^8.0.3" - }, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", @@ -19,7 +10,18 @@ "dependencies": { "core-js": "^3.8.3", "element-plus": "^2.3.12", - "vue": "^3.2.13" + "vue": "^3.2.13", + "vue-router": "^4.0.3" + }, + "devDependencies": { + "@babel/core": "^7.12.16", + "@babel/eslint-parser": "^7.12.16", + "@vue/cli-plugin-babel": "~5.0.0", + "@vue/cli-plugin-eslint": "~5.0.0", + "@vue/cli-plugin-router": "~5.0.0", + "@vue/cli-service": "~5.0.0", + "eslint": "^7.32.0", + "eslint-plugin-vue": "^8.0.3" }, "eslintConfig": { "root": true, @@ -41,6 +43,6 @@ "not dead", "not ie 11" ], - "readme": "ERROR: No README data found!", - "_id": "vue3_element_demo1@0.1.0" -} \ No newline at end of file + "_id": "vue3_element_demo1@0.1.0", + "readme": "ERROR: No README data found!" +} diff --git a/src/App.vue b/src/App.vue index 29d209e..9dd79de 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,35 +1,7 @@ - - - - - {{ tips }} - - - - 我的错误是{{ slot_data_types.types['500'] }} - - - - - 错误来自:{{ sources['page'] }} - {{ types['404'] }} - - + + Home | + About + + - - - - diff --git a/src/main.js b/src/main.js index 2703293..ff25769 100644 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,5 @@ import {createApp} from "vue"; import App from "./App.vue" +import router from './router' -createApp(App).mount('#app') +createApp(App).use(router).mount('#app') diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..083231b --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,22 @@ +import { createRouter, createWebHashHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' + +const routes = [ + { + path: '/', + name: 'home', + component: HomeView + }, + { + path: '/about', + name: 'about', + component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue') + } +] + +const router = createRouter({ + history: createWebHashHistory(), + routes +}) + +export default router diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue new file mode 100644 index 0000000..56b5bc9 --- /dev/null +++ b/src/views/AboutView.vue @@ -0,0 +1,3 @@ + + 这是About + diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue new file mode 100644 index 0000000..8af0b4b --- /dev/null +++ b/src/views/HomeView.vue @@ -0,0 +1,3 @@ + + 这是Home +
{{ tips }}
我的错误是{{ slot_data_types.types['500'] }}