Home > Web Front-end > JS Tutorial > 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

黄舟
Release: 2017-07-17 12:00:34
Original
2283 people have browsed it

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 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>
Copy after login

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
   }
  }
 ]
})
Copy after login

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
   }   
  }
 ]
})
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template