• vue进行路由拼图的使用案例


    实现思路,利用路由进行实现多个组件拼图:

    Detail.vue

    <template>
        <div>
          <h1>详细展示</h1>
          <div>鞍山市所所所所所所所所所所所所所所所所所所所所</div>
        </div>
    </template>
    
    <script>
    
    </script>

    Header.vue

    <template>
        <div>
          <h1>标题栏</h1>
          <div>欢迎</div>
        </div>
    </template>
    
    <script>
    
    </script>
    
    <style scoped>
    
    </style>
    Sidebar.vue
    <template>
        <div>
          <h1>边条</h1>
        </div>
    </template>
    
    <script>
    
    </script>
    
    <style scoped>
    
    </style>

    在router下index.js中引入

    import Vue from 'vue'
    import Router from 'vue-router'
    import Detail from '../components/Detail'
    import MyHeader from '../components/Header'
    import Sidebar from '../components/Sidebar'
    Vue.use(Router)
    
    export default new Router({
      routes: [
        {
          path: '/',
          name: 'Home',
          components: {
            myHeader: MyHeader,
            mySidebar: Sidebar,
            myDetail: Detail
          }
        }
      ]
    })

    注意事项:

     app.vue

    <template>
      <div id="app">
        <table width="100%">
          <tr>
            <td colspan="2" style="background-color:darkgoldenrod">
              <router-view name="myHeader"></router-view>
            </td>
          </tr>
          <tr>
            <td width="20%" style="background-color:thistle">
              <router-view name="mySidebar"></router-view>
            </td>
            <td width="80%" style="background-color:aquamarine">
              <router-view name="myDetail"></router-view>
            </td>
          </tr>
        </table>
      </div>
    </template>
    
    <script>
    export default {
      name: 'App'
    }
    </script>
    
    <style>
    
    </style>
    最终运行结果:



  • 相关阅读:
    loj #143. 质数判定
    Quadratic Residues POJ
    P2155 [SDOI2008]沙拉公主的困惑
    P3868 [TJOI2009]猜数字
    P3704 [SDOI2017]数字表格
    P4449 于神之怒加强版
    P2568 GCD
    P1891 疯狂LCM
    loj#6229 这是一道简单的数学题
    P3768 简单的数学题 杜教筛+推式子
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10766494.html
Copyright © 2020-2023  润新知