跳到主要内容
CNode

关于 vue-router 的编写

问答
Vvxhly发布于 9 年前最后回复 9 年前
946260

父组件是Home.vue,子组件是 UpHeader.vue和UpFooter.vue

截图中的写法不能实现引入两个组件,各位大佬有没有办法解决 image.png

image.png

查看回复

回复 (9)

V
vxhly#89 年前
引用 pythonsoft第一种写法vue router,不需要children,children表示本页的子页面,你本意是在本页使用子组件,应该改成这样 routers: [ path: '/', name: 'ho...

@pythonsoft 没毛病,引用的时候就是得写成

<up-header></up-header>
<script>
import UpHeader from '........'
</script>
V
vxhly#79 年前

已解决了,只要在父组件里面 import 就行了 image.png

X
xiaobaicai#59 年前

path.png楼主你文件路径里的这个'@'代表啥啊

P
pythonsoft#49 年前

第一种写法vue-router,不需要children,children表示本页的子页面,你本意是在本页使用子组件,应该改成这样 routers: [ path: '/', name: 'home', component: Home, components: { 'up-header': Upheader, 'up-footer': UpFooter } ]

第二种写法,主要在你使用子组件的名字up-header不对 export default { name: 'home', components: { 'up-header': UpHeader, 'up-footer': UpFooter } }

M
madgecool#39 年前
H
htoooth#29 年前

没有看懂,如果你只想引用子组件的化,直接在 home 中使用 components 引入,之后当组件使用

M
MiYogurt#19 年前

.vue 加上。

参与回复

登录后即可参与回复。登录