<template>
<div class="layout">
<header>
<!-- 头部区域 -->
<h1>Vue Layout</h1>
</header>
<main>
<!-- 主要内容区域 -->
<router-view></router-view>
</main>
<footer>
<!-- 底部区域 -->
<p>© 2023 Vue Layout Example</p>
</footer>
</div>
</template>
<script>
export default {
name: 'App',
};
</script>
<style scoped>
.layout {
display: flex;
flex-direction: column;
min-height: 100vh;
}
header, footer {
background-color: #f8f9fa;
padding: 1rem;
text-align: center;
}
main {
flex-grow: 1;
padding: 1rem;
}
</style>
<template>: 定义了页面的布局结构,包含头部 (<header>)、主要内容区域 (<main>) 和底部 (<footer>)。<router-view>: 这是一个占位符,用于显示当前路由对应的组件内容。它会根据路由的变化动态渲染不同的视图。<script>: 定义了一个名为 App 的 Vue 组件,它是整个应用的根组件。<style scoped>: 使用了 scoped 样式,确保这些样式只应用于当前组件。布局采用了 Flexbox 布局方式,使得页面可以自适应高度,并且主要内容区域能够自动扩展以填充剩余空间。如果你需要更复杂的布局或功能,请根据具体需求进行调整。
上一篇:vue form
下一篇:vue 下拉框
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站