问答

vue项目怎么建一个布局,让其中间部分可替换,上边固定不动?

作者:admin 2021-04-21 我要评论

我现在这样写的,之后不知道怎么用?其它页面都要这个模板,登录页不用,怎么写? template div h2header/h2 div class="container" keep-alive router-view/rout...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

我现在这样写的,之后不知道怎么用?其它页面都要这个模板,登录页不用,怎么写?

<template>
    <div>
        <h2>header</h2>
        <div class="container">
            <keep-alive>
                <router-view></router-view>
            </keep-alive>
        </div>
    </div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component
export default class HelloWorld extends Vue {}
</script>
<style lang="scss" scoped>
</style>
###

要引入vue-router
然后配置路由项,类似于下面这样

// 这个layout就是你上面定义的布局
import Layout from '@/layout'

const router = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/else',
    component: Layout,
    children: [{
      path: 'one',
      component: () => import('@/views/one')
    }]
  },
]

当你调用/else/one 页面时,会先使用 你的布局 在使用 one 组件的布局这样就行了

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • vue项目怎么建一个布局,让其中间部分

    vue项目怎么建一个布局,让其中间部分

  • 我想复选框显示隐藏全部标记。

    我想复选框显示隐藏全部标记。

  • icon跨域问题

    icon跨域问题

  • 有没有什么好的软件,可以用于整理某个

    有没有什么好的软件,可以用于整理某个

腾讯云代理商
海外云服务器