Home  >  Article  >  Web Front-end  >  An example analysis of how Vue.js operates multiple routing areas on a single page

An example analysis of how Vue.js operates multiple routing areas on a single page

黄舟
黄舟Original
2017-07-17 12:00:342220browse

This article mainly introduces Vue.js single page multiple routingRelated information about detailed examples of regional operations. Friends in need can refer to

Single page multiple routing regional operations

If there are two or more 975b587bf85a482ea10b0a28848e78a4 areas in a page, you need to set the index.js of the route to operate the contents of these areas

App.vue Settings in index.js:

<router-view></router-view>
<router-view name="left" style="float: left;width: 50%; height: 300px;background-color: #ccc;"></router-view>
<router-view name="right" style="float: left;width: 50%; height: 300px;background-color: #898;"></router-view>

Settings in index.js:

import Vue from &#39;vue&#39;
import Router from &#39;vue-router&#39;
import Hello from &#39;@/components/Hello&#39;
import First1 from &#39;@/components/first1&#39;
import First2 from &#39;@/components/first2&#39;

Vue.use(Router)

export default new Router ({
 routes : [
  {
   path : &#39;/&#39;,
   name : &#39;Hello&#39;,
   components : {
    default : Hello,
    left : First1,
    right : First2
   }
  }
 ]
})

The following settings are to exchange the two components for display when the url is /#/first location

export default new Router ({
 routes : [
  {
   path : &#39;/&#39;,
   name : &#39;Hello&#39;,
   components : {
    default : Hello,
    left : First1,
    right : First2
   }
  }, {
   path : &#39;/first&#39;,
   name : &#39;First&#39;,
   components : {
    default : Hello,
    left : First2,
    right : First1
   }   
  }
 ]
})

The above is the detailed content of An example analysis of how Vue.js operates multiple routing areas on a single page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn