-組件的使用
<!-- 1、父組件中引入組件 import Home from "./components/Home";
2、注冊組件 components:{'v-home':Home,},
3、使用組件 <v-home></v-home>
-->
-路由及組件跳轉
<!--
1、安裝並保存
npm install vue-router --save
2、在main.js里引入並使用
import VueRouter from 'vue-router'
Vue.use(VueRouter)
3、在main.js里路由配置
1.創建組件 引入組件
import Router from "./components/06Router";
2.定義路由
const routes = [
{path:'/router',component:Router},
{path:'/bar',component:Bar}
]
3.實例化VueRouter
const router=new VueRouter({
routes //縮寫(routes:routes)
})
4.掛載
new Vue({
el:'#app',
router,
render:h => h(App)
})
5.在App.vue里使用(路由匹配到的組件將顯示在這里)
<router-view></router-view>
-->