File tree Expand file tree Collapse file tree 11 files changed +100
-146
lines changed Expand file tree Collapse file tree 11 files changed +100
-146
lines changed Original file line number Diff line number Diff line change 1+ import Vue from "vue" ;
2+ import router from "./router" ;
3+
4+ Vue . config . productionTip = false ;
5+
6+ export default {
7+ start
8+ }
9+
10+ function start ( ) {
11+ new Vue ( {
12+ router,
13+ render ( h ) {
14+ return h ( 'div' , {
15+ attrs : {
16+ id : 'app'
17+ }
18+ } , [
19+ h ( 'keep-alive' , [
20+ this . $route . meta . keepAlive ? h ( 'router-view' ) : ''
21+ ] ) ,
22+ ! this . $route . meta . keepAlive && h ( 'router-view' )
23+ ] )
24+ }
25+ } ) . $mount ( "#app" ) ;
26+ }
27+
28+
Original file line number Diff line number Diff line change 1+ import Vue from "vue"
2+ import Router from "vue-router"
3+ import NotFoundComponent from '@/components/notFoundComponent.vue'
4+
5+ Vue . use ( Router ) ;
6+
7+ export default new Router ( {
8+ mode : "history" ,
9+ base : process . env . BASE_URL ,
10+ scrollBehavior,
11+ routes : [ {
12+ path : '*' ,
13+ component : NotFoundComponent
14+ } ]
15+ } ) ;
16+
17+ function scrollBehavior ( to :any , from :any , savedPosition :any ) {
18+ if ( savedPosition ) {
19+ return savedPosition ;
20+ } else {
21+ return {
22+ x : 0 ,
23+ y : 0
24+ } ;
25+ }
26+ }
27+
28+ window . addEventListener ( 'popstate' , function ( e ) {
29+ console . log ( e )
30+ } )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export default vue.extend({
2121 },
2222 toAbout() {
2323 this .$router .push ({path: ' /about' })
24+ // window.location.href ='../about'
2425 },
2526 }
2627})
Original file line number Diff line number Diff line change 44</template >
55
66<script >
7- export default {
7+ import vue from ' vue'
8+ export default vue .extend ( {
89 data () {
910 return {
1011 };
@@ -17,7 +18,7 @@ export default {
1718 mounted () {},
1819
1920 methods: {}
20- }
21+ })
2122
2223 </script >
2324<style lang='scss' scoped>
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import app from '@/app/index'
2+ import './router/router'
3+
4+ export default app . start ( )
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import Vue from "vue"
2- import Router from "vue- router"
3- import { reloadIfNotFound } from './hooks'
1+
2+ import router from "@/app/ router"
3+
44import NotFoundComponent from '@/components/notFoundComponent.vue'
55import Home from '@/views/home/home.vue'
66
7- Vue . use ( Router ) ;
8-
9- const router = new Router ( {
10- mode : "history" ,
11- base : process . env . BASE_URL ,
12- scrollBehavior,
13- routes : [
14- { path : '*' , component : NotFoundComponent } ,
15- {
16- path : "/home/home" ,
17- name : "home" ,
18- component : Home
7+ let routes = [
8+ { path : '*' , component : NotFoundComponent } ,
9+ {
10+ path : "/home/home" ,
11+ name : "home" ,
12+ component : Home ,
13+ meta : {
14+ keepAlive : true ,
15+ } ,
16+ } ,
17+ {
18+ path : "/home/abc" ,
19+ name : "abc" ,
20+ meta : {
21+ keepAlive : true ,
1922 } ,
20- {
21- path : "/ home/abc" ,
22- name : "abc" ,
23- meta : {
24- keepAlive : true ,
25- } ,
26- component : ( ) =>
27- import ( /* webpackChunkName: "home/abc" */ "@/views/home/abc.vue" )
23+ component : ( ) =>
24+ import ( /* webpackChunkName : "home/abc" */ "@/views/ home/abc.vue" )
25+ } ,
26+ {
27+ path : "/about" ,
28+ name : "about" ,
29+ meta : {
30+ keepAlive : true ,
2831 } ,
29- {
30- path : "/about" ,
31- name : "about" ,
32- meta : {
33- keepAlive : true ,
34- } ,
35- component : ( ) =>
36- import ( /* webpackChunkName: "home/about" */ "@/views/about.vue" )
37- }
38- ]
39- } ) ;
32+ component : ( ) =>
33+ import ( /* webpackChunkName: "home/about" */ "@/views/about.vue" )
34+ }
35+ ]
4036
41- router . beforeEach ( reloadIfNotFound ) ;
37+ router . addRoutes ( routes )
38+
39+ export default router
4240
43- export default router ;
4441
45- function scrollBehavior ( to :any , from :any , savedPosition :any ) {
46- if ( savedPosition ) {
47- return savedPosition ;
48- } else {
49- return {
50- x : 0 ,
51- y : 0
52- } ;
53- }
54- }
You can’t perform that action at this time.
0 commit comments