Vue路由-命名视图实现经典布局

Vue路由-命名视图实现经典布局

相关Html:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./lib/vue-2.4.0.js"></script>
  <script src="./lib/vue-router-3.0.1.js"></script>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
    }

    .header {
      background-color: orange;
      height: 80px;
    }

    h1 {
      margin: 0;
      padding: 0;
      font-size: 16px;
    }

    .container {
      display: flex;
      height: 600px;
    }

    .left {
      background-color: lightgreen;
      flex: 2;
    }

    .main {
      background-color: lightpink;
      flex: 8;
    }
  </style>
</head>

<body>
  <div id="app">

    <router-view></router-view>
    <div class="container">
      <router-view name="left"></router-view>
      <router-view name="main"></router-view>
    </div>

  </div>

  <script>

    var header = {
      template: '<h1 class="header">Header头部区域</h1>'
    }

    var leftBox = {
      template: '<h1 class="left">Left侧边栏区域</h1>'
    }

    var mainBox = {
      template: '<h1 class="main">mainBox主体区域</h1>'
    }

    // 创建路由对象
    var router = new VueRouter({
      routes: [
        /* { path: '/', component: header },
        { path: '/left', component: leftBox },
        { path: '/main', component: mainBox } */

        {
          path: '/', components: {
            'default': header,
            'left': leftBox,
            'main': mainBox
          }
        }
      ]
    })

    // 创建 Vue 实例,得到 ViewModel
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      router
    });
  </script>
</body>

</html>

原文地址:https://www.cnblogs.com/charlypage/p/9912117.html

时间: 2024-07-30 04:14:56

Vue路由-命名视图实现经典布局的相关文章

vue中命名视图实现经典布局

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" con

Vue系列之 =&gt; 命名视图实现经典布局

1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta charset="utf-8"> 6 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 7 <meta http-equiv="Content-Type&quo

Vue路由钩子 afterEach beforeEach区别

? vue-router作为vue里面最基础的服务,学习一段时间,对遇到的需求进行一些总结 使用vue-cli作为开发前提 vue-router已经配置好了 路由写法 routes: [ { path: '/cart', name: 'cart', component: cart, meta :{ title: "购物车"} //用于给定网页名 } ] vue-router 的路由跳转的方法 第一种 : 编程式的导航 <router-link to="/" t

14.vue路由&amp;脚手架

一.vue路由:https://router.vuejs.org/zh/ 1.定义 let router = new VueRouter({ mode:"history/hash", base:"基本路径" 加一些前缀 必须在history模式下有效 linkActiveClass:"active", 范围选择 linkExactActiveClass:"exact", 精确选择 routes:[ {path,componen

Vue路由传递参数详细说明

前言:最近我跟同事在做一个BI系统,采用前后端分离.整个系统包括数据分析系统.运营支持.系统设置等多个子系统.数据分析系统其实就是做各种数据报表.数据统计.实时数据的系统,这里面其实整个页面就是一个模板,最上面是filter.第二级是统计图.最下面是table数据.所以在数据分析子系统中,只要配置一个路由就可以匹配所有页面,在系统中,我把这个为公用路由.至于公用路由权限如何鉴定其实很简单:获取到用户权限列表后,渲染出所有的权限菜单,但注意每次跳转时一定要进行权限校验,具体原因自行思考.说着有点跑

vue路由-router

VueRouter基础 vue路由的注册 导入 <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script> # 可以是下载之后的 <script src="vue.min.js"></script> <script src="vue-router.js"></script> 定义一个匹配规则对

New UI-&lt;merge&gt;标签减少视图层级,让布局更高效

New UI-<merge>标签减少视图层级,让布局更高效  --转载请注明出处:coder-pig,欢迎转载,请勿用于商业用途! 小猪Android开发交流群已建立,欢迎大家加入,无论是新手,菜鸟,大神都可以,小猪一个人的 力量毕竟是有限的,写出来的东西肯定会有很多纰漏不足,欢迎大家指出,集思广益,让小猪的博文 更加的详尽,帮到更多的人,O(∩_∩)O谢谢! 小猪Android开发交流群:小猪Android开发交流群群号:421858269 新Android UI实例大全目录:http://

vue 路由介绍

1.带参数的路由 export default new Router({ mode: 'history', //去掉# routes: [ { path: '/apple/:color', name: 'Apple', component: Apple }, ] })apple路由页面必须加上参数否则匹配不到页面,带引号的都是参数 :color也可以是这样的 /apple/:color/detail/:type通过this.$route.param 获取参数 参数为{color:red,type

vue路由原理

Vue路由原理 目前实现路由的方式有两中,vue通过参数mode来设置,默认是hash模式. 利用URL中的hash('#')来实现 利用History interface在HTML5中新增的方法 history对应的是HTML5History对象,hash对应的是HashHistory对象,abstract对应的是AbstractHistory对象.在初始化对应的history之前,会对mode做一些校验:若浏览器不支持HTML5History方式(通过supportsPushState遍历判