webstorm-vueCli 组件的嵌套

1项目截图

图片.png

account.vue
login.vue
register.vue

<template>
  <div>
    <h1>这是Account组件</h1>
    <router-link to="/account/login">登录</router-link>
    <router-link to="/account/register">注册</router-link>

    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'Account'
}
</script>

<style scoped>

</style>

<template>
    <div>登录</div>
</template>

<script>
    export default {
        name: "login"
    }
</script>

<style scoped>

</style>

<template>
    <div>注册</div>
</template>

<script>
    export default {
        name: "login"
    }
</script>

<style scoped>

</style>

2

index.js
App.vue
main.js

import Vue from 'vue'
import Router from 'vue-router'
import account from '@/components/Account'
import login from '@/components/login'
import register from '@/components/register'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)

export default new Router({
  routes: [
    {path: '/', name: 'HelloWorld', component: HelloWorld},
   /* /!*{path:'/account',component:account,children:[
        {path:'login',component:login},

      ]},*!/
    {path:'/login',component:login},*/

    {path:'/account',component:account,children:[
        {path:'login',component:login},
        {path:'register',component:register},
      ]},
  ]
})

app.vue

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <h3>首页</h3>
    <router-link to="/account">account</router-link>
    <router-view></router-view>
  </div>
</template>

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

图片.png
图片.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • jHipster - 微服务搭建 CC_简书[https://www.jianshu.com/u/be0d56c4...
    quanjj阅读 843评论 0 2
  • # 传智播客vue 学习## 1. 什么是 Vue.js* Vue 开发手机 APP 需要借助于 Weex* Vu...
    再见天才阅读 3,629评论 0 6
  • vue-cli搭建项目 确保安装了node与npm 再目标文件夹下打开终端 执行cnpm i vue-cli -g...
    Akiko_秋子阅读 3,278评论 1 22
  • 作者信息: Author : 黄志成(小黄)博客地址: 博客 dis模块通过反汇编来支持CPython 字节码的分...
    温柔小黄阅读 1,309评论 0 1
  • 炎炎夏日,骄阳似火。 人的心也跟着焦灼不定,一天天沉迷于安逸中。一点一滴地磨灭了激情与自信。 没有了曾经的动力和追...
    艾瑞芭迪阅读 264评论 0 0