Skip to content

Commit

Permalink
1-完成了项目的初始化及路由配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Duanzihuang committed Jul 10, 2020
1 parent 63ae3aa commit 12a7bd1
Show file tree
Hide file tree
Showing 11 changed files with 401 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
node: true
},
extends: [
'plugin:vue/essential',
'plugin:vue/vue3-essential',
'@vue/standard',
'@vue/typescript/recommended'
],
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"semi": false
}
397 changes: 359 additions & 38 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue": "^3.0.0-beta.1",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.2",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
"vue-router": "^4.0.0-alpha.6",
"vuex": "^4.0.0-alpha.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.33.0",
Expand All @@ -24,17 +24,18 @@
"@vue/cli-plugin-typescript": "~4.4.0",
"@vue/cli-plugin-vuex": "~4.4.0",
"@vue/cli-service": "~4.4.0",
"@vue/compiler-sfc": "^3.0.0-beta.1",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^5.0.2",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"eslint-plugin-vue": "^7.0.0-alpha.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2",
"typescript": "~3.9.3",
"vue-template-compiler": "^2.6.11"
"vue-cli-plugin-vue-next": "~0.1.3"
}
}
29 changes: 1 addition & 28 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
<router-view />
</div>
</template>

<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>
10 changes: 2 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import Vue from 'vue'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
createApp(App).use(router).use(store).mount('#app')
29 changes: 20 additions & 9 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import { RouteConfig, createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
redirect: '/home'
},
{
path: '/home',
name: 'Index', // name不能为Home,否则路由不起作用
component: Home
},
{
path: '/list/:type',
name: 'List',
component: () => import('@/views/List.vue')
},
{
path: '/detail/:id',
name: 'Home',
component: () => import('@/views/Detail.vue')
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
component: () =>
import(/* webpackChunkName: "about" */ '../views/About.vue')
}
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})

Expand Down
5 changes: 1 addition & 4 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
export default Vuex.createStore({
state: {
},
mutations: {
Expand Down
3 changes: 3 additions & 0 deletions src/views/Detail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>详情页面</div>
</template>
17 changes: 1 addition & 16 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
<div>Home</div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'Home',
components: {
HelloWorld
}
}
</script>
3 changes: 3 additions & 0 deletions src/views/List.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>列表页面</div>
</template>

0 comments on commit 12a7bd1

Please sign in to comment.