欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解vue-router 命名路由和命名視圖

 更新時間:2018年06月01日 08:32:55   作者:侯婧歡  
這篇文章主要介紹了詳解vue-router 命名路由和命名視圖,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

說明:vue-router的幾個文章中例子是連貫的,因此對哪塊有疑問請翻閱按發(fā)表時間排序的其他文章。

一、概述

  1. 給路由定義不同的名字,根據(jù)名字進行匹配
  2. 給不同的router-view定義名字,router-link通過名字進行對應(yīng)組件的渲染。

二、代碼展示:

目錄視圖

1、命名路由

 

2、命名視圖

index.js

import Vue from 'vue'
import Router from 'vue-router'
import Goodlists from '@/Goodlists/goods'
import Title from '@/Goodlists/title'
import Img from '@/Goodlists/img'
import Cart from '@/Goodlists/cart'
Vue.use(Router)
export default new Router({
 routes: [
 {
 path: '/goods',
 name: 'Goodlists',
 components:{
 default:Goodlists,
 title:Title,
 image:Img,
 } 
 } 
 ]
})

App.vue

<template>
 <div id="app">
 <img src="./assets/logo.png">
 <router-view></router-view>
 <router-view name="title" class="left"></router-view>
 <router-view name="image" class="right"></router-view>
 </div>
</template>

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

<style>
#app {
 font-family: 'Avenir', Helvetica, Arial, sans-serif;
 -webkit-font-smoothing: antialiased;
 -moz-osx-font-smoothing: grayscale;
 text-align: center;
 color: #2c3e50;
 margin-top: 60px;
}
.left,.right{
 float: left;
 width:48%;
 text-align: center;
 border:1px solid red
}
</style>

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論