美文网首页
组件模板结合(组件群)

组件模板结合(组件群)

作者: baronL | 来源:发表于2019-02-14 23:48 被阅读0次

组件模板结合(组件群)

import Vue from 'vue'
// 引入vue
import VueRouter from 'vue-router'
// 引入vue路由
// 使用vue路由
Vue.use(VueRouter)
// 定义模板
const First = { template: '<div>First的第一个内容</div>' }
const second = { template: '<div>secode的内哦荣</div>' }
const Home = { template: '<div>根目录的内容的内容</div>' }
// eslint-disable-next-line standard/object-curly-even-spacing
const hehe = { template: '<div>hehe的内容</div>'}

const router = new VueRouter({
  // 模式history,记住就好
  mode: 'history',
  //    当前的根目录为基础路径
  base: __dirname,
  //   注意注意:这里的不是router,也不是routers,而是routes
  routes: [
    { path: '/',
      components: {
        default: Home,
        left: First,
        right: second
      }},
    { path: '/first',
      components: {
        // eslint-disable-next-line no-undef
        default: hehe,
        left: First,
        one: second
      }}
  ]
})
// 写模板
new Vue({
  router,
  template: `
     <div id='r'>
      <h1>导航</h1>
      <p>{{$route.name}}</p>
       <ol>
            <li><router-link to='/'>/</router-link></li>
            <li><router-link to='/first'>First</router-link></li>
       </ol>

    //    <router-view></router-view>呈现页面的  
       <router-view name="left" style="float:left;height:200px;width:50%;background-color:red;"></router-view>  
       <router-view name="right" style="float:left;height:200px;width:50%;background-color:blue;"></router-view>  
       <router-view name="one" style="float:left;height:200px;width:50%;background-color:black;"></router-view>  
     </div>
    `
}).$mount('#app')

相关文章

  • 组件模板结合(组件群)

    组件模板结合(组件群)

  • 自定义组件:模板和样式

    原文链接:组件模板和样式 组件模板 组件模板的写法与页面模板相同。组件模板与组件数据结合后生成的节点树,将被插入到...

  • 微信小程序slot使用例子

    组件模板的写法与页面模板相同。组件模板与组件数据结合后生成的节点树,将被插入到组件的引用位置上。 在组件模板中可以...

  • 微信小程序中自定义组件slot的使用

    1.slot是什么? 组件模板的写法与页面模板相同。组件模板与组件数据结合后生成的节点树,将被插入到组件的引用位置...

  • 学习微信小程序(3)——组件

    一、自定义组件 1、组件模版和样式 组件模版组件模版的写法与页面模板相同。组件模版与组件数据结合后生成的节点树,将...

  • wepy 模板

    页面模板: 组件模板: mixin 模板: 常用for 循环,组件循环要用repeat

  • 47-Vue组件render

    这里显示组件的方法对比 一.注册子组件 定义组件模板 创建模板对象 绑定模板组件 二.利用render渲染 直接点...

  • 学习vue组件之间的跳转

    写好子组件模板以后在父组件模板中通过@click=‘componentName=‘子组件名字’’,定义跳转的子组件...

  • Vue03

    Vue组件 一、组件介绍 每一个组件都是一个vue实例 每个组件均具有自身的模板template,根组件的模板就是...

  • Vue (三)

    Vue组件 一、组件介绍 每一个组件都是一个vue实例 每个组件均具有自身的模板template,根组件的模板就是...

网友评论

      本文标题:组件模板结合(组件群)

      本文链接:https://www.haomeiwen.com/subject/krayeqtx.html