Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
V
vue-demo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amy Yang
vue-demo
Commits
945af8e8
Commit
945af8e8
authored
Jan 27, 2021
by
Amy Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
e02c2ca8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
8 deletions
+136
-8
index.js
vue-demo/src/router/index.js
+11
-7
test.js
vue-demo/src/router/modules/test.js
+21
-0
Login.vue
vue-demo/src/views/auth/Login.vue
+0
-0
AppLayout.vue
vue-demo/src/views/layouts/AppLayout.vue
+85
-0
About.vue
vue-demo/src/views/test/About.vue
+17
-0
Home.vue
vue-demo/src/views/test/Home.vue
+0
-0
vue.config.js
vue-demo/vue.config.js
+2
-1
No files found.
vue-demo/src/router/index.js
View file @
945af8e8
import
Vue
from
'vue'
import
VueRouter
from
'vue-router'
import
test
from
'./modules/test'
Vue
.
use
(
VueRouter
)
const
routes
=
[
{
path
:
'/'
,
name
:
'Login'
,
component
:
()
=>
import
(
/* webpackChunkName: "about" */
'../views/Login.vue'
)
component
:
()
=>
import
(
/* webpackChunkName: "about" */
'../views/
auth/
Login.vue'
)
},
{
path
:
'/
about
'
,
name
:
'
About
'
,
path
:
'/
login
'
,
name
:
'
Login
'
,
// 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: "
Login" */
'../views/auth/Login
.vue'
)
},
{
path
:
'/
login
'
,
name
:
'
Login
'
,
path
:
'/
index
'
,
name
:
'
AppLayout
'
,
// 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/Login.vue'
)
component
:
()
=>
import
(
/* webpackChunkName: "AppLayout" */
'../views/layouts/AppLayout.vue'
),
children
:
[
test
]
}
]
...
...
vue-demo/src/router/modules/test.js
0 → 100644
View file @
945af8e8
const
routes
=
{
path
:
'/test'
,
name
:
'Test'
,
component
:
{
template
:
'<router-view></router-view>'
},
children
:
[
{
path
:
'about'
,
name
:
'About'
,
component
:
()
=>
import
(
'@/views/test/About.vue'
)
},
{
path
:
'home'
,
name
:
'Home'
,
component
:
()
=>
import
(
'@/views/test/Home.vue'
)
}
]
}
export
default
routes
vue-demo/src/views/Login.vue
→
vue-demo/src/views/
auth/
Login.vue
View file @
945af8e8
File moved
vue-demo/src/views/layouts/AppLayout.vue
0 → 100644
View file @
945af8e8
<
template
>
<v-app
id=
"inspire"
>
<v-navigation-drawer
v-model=
"drawer"
app
>
<!-- 第五行app去掉后,整个工具栏延伸到左侧导航菜单上方 -->
<v-list
expand
dense
>
<template
v-for=
"(route, index) in routes"
>
<template
v-if=
"route.children"
>
<v-list-group
:key=
"index"
>
<template
v-slot:activator
>
<v-list-item-content>
<v-list-item-title
v-text=
"route.name"
ripple
></v-list-item-title>
</v-list-item-content>
</
template
>
<v-list-item
v-for=
"(cRoute, idx) in route.children"
:key=
"idx"
:to=
"{ name: cRoute.name }"
>
<v-list-item-action>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title
v-text=
"cRoute.name"
></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-group>
</template>
<
template
v-else
>
<v-list-item
:key=
"index"
:to=
"
{ name: route.name }">
<v-list-item-action>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title
v-text=
"route.name"
></v-list-item-title>
</v-list-item-content>
</v-list-item>
</
template
>
</template>
</v-list>
</v-navigation-drawer>
<v-app-bar
app
>
<v-app-bar-nav-icon
@
click
.
stop=
"drawer = !drawer"
></v-app-bar-nav-icon>
<v-toolbar-title>
Application
</v-toolbar-title>
</v-app-bar>
<v-main>
<router-view
/>
</v-main>
<v-footer
app
>
<span
class=
"black--text"
>
©
{{ new Date().getFullYear() }}
</span>
</v-footer>
</v-app>
</template>
<
script
>
export
default
{
data
()
{
return
{
drawer
:
null
}
},
computed
:
{
routes
()
{
const
routeName
=
this
.
$route
.
name
const
{
routes
}
=
this
.
$router
.
options
try
{
for
(
let
i
=
0
,
len
=
routes
.
length
;
i
<
len
;
i
+=
1
)
{
if
(
routes
[
i
].
children
)
{
for
(
let
j
=
0
,
len
=
routes
[
i
].
children
.
length
;
j
<
len
;
j
+=
1
)
{
const
child
=
routes
[
i
].
children
[
j
]
if
(
child
.
name
===
routeName
)
{
return
routes
[
i
].
children
}
}
}
else
if
(
routes
[
i
].
name
===
routeName
)
{
return
routes
[
i
]
}
}
}
catch
(
err
)
{
console
.
log
(
'>>>sidebar'
,
err
)
}
return
routes
[
2
].
children
}
}
}
</
script
>
vue-demo/src/views/About.vue
→
vue-demo/src/views/
test/
About.vue
View file @
945af8e8
...
...
@@ -3,3 +3,15 @@
<h1>
This is an about page
</h1>
</div>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
}
},
beforeCreate
()
{
console
.
log
(
this
.
$router
)
}
}
</
script
>
vue-demo/src/views/Home.vue
→
vue-demo/src/views/
test/
Home.vue
View file @
945af8e8
File moved
vue-demo/vue.config.js
View file @
945af8e8
module
.
exports
=
{
transpileDependencies
:
[
'vuetify'
]
],
runtimeCompiler
:
true
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment