<FmPageLayout> 页面布局组件是本框架区别于其他 H5 框架的最重要的特性。它提供了页面整体布局的基础,包括顶部导航栏、顶部标签栏、返回顶部、记录滚动位置等特性。
<template>
<FmPageLayout :navbar="false" tabbar copyright>
<!-- ... -->
</FmPageLayout>
</template>本组件不是一个可以随处使用的组件,它必须应用在根节点,并且一个页面里只能有一个 <FmPageLayout> 组件。
booleantruebooleanundefinednavbar.enable'fixed' | 'static' | 'show-hide-fixed' | 'sticky'undefinednavbar.modenavbarSideOptions | navbarSideOptions[]undefinedtype navbarSideOptions = 'back' | 'home' | 'forward' | 'i18n' | 'colorScheme'navbarSideOptions | navbarSideOptions[]undefinedtype navbarSideOptions = 'back' | 'home' | 'forward' | 'i18n' | 'colorScheme'booleantruebooleanfalsebooleanfalsestringundefinedbooleanundefinedtabbar.enable'fixed' | 'sticky'undefinedtabbar.modestringundefinedbooleantruebooleanfalsebooleanfalsestringundefinedbooleanundefinedcopyright.enablebooleanundefinedapp.enableBackTopbooleanundefinednumberundefinednumberundefinedbooleanundefined页面内容区域
导航栏标题区域
导航栏左侧图标区域
导航栏右侧图标区域
导航栏下方额外区域
标签栏区域
标签栏下方额外区域
页面滚动时触发
页面滚动到顶部时触发
页面滚动到底部时触发
可以将导航栏全局开启,这样所有页面默认都会显示导航栏。
const globalSettings: Settings.all = {
navbar: {
enable: true,
},
}或者也可以提供一段正则表达式,例如下面这段配置表示页面在微信环境下默认不显示导航栏:
const globalSettings: Settings.all = {
navbar: {
enable: !/MicroMessenger/i.test(window.navigator.userAgent),
},
}全局设置导航栏模式,默认为 fixed
'fixed' 固定,不跟随页面滚动,始终固定在顶部'static' 静止,跟随页面滚动'show-hide-fixed' 显隐固定,默认隐藏,页面滚动时显示'sticky' 粘性,页面往下滚动时隐藏,往上滚动时显示const globalSettings: Settings.all = {
navbar: {
mode: 'fixed',
},
}可以将标签栏全局开启,这样所有页面默认都会显示标签栏。
const globalSettings: Settings.all = {
tabbar: {
enable: true,
},
}全局设置标签栏模式,默认为 fixed
'fixed' 固定,不跟随页面滚动,始终固定在底部'sticky' 粘性,页面往下滚动时隐藏,往上滚动时显示const globalSettings: Settings.all = {
tabbar: {
mode: 'sticky',
},
}标签栏展示数据:
const globalSettings: Settings.all = {
tabbar: {
list: [
{
path: '/',
icon: 'i-ic:sharp-home',
text: '主页',
},
{
path: '/user',
icon: 'i-ic:baseline-person',
text: '我的',
},
],
},
}专业版支持配置多套标签栏,然后通过 tabbarName 属性指定当前页面使用哪套标签栏:
const globalSettings: Settings.all = {
tabbar: {
list: [
{
name: 'tabbar1',
list: [
{
path: '/',
icon: 'i-ic:sharp-home',
text: '主页',
},
{
path: '/user',
icon: 'i-ic:baseline-person',
text: '我的',
},
],
},
{
name: 'tabbar2',
list: [
{
path: '/list',
icon: 'i-ic:sharp-list',
text: '列表',
},
{
path: '/setting',
icon: 'i-ic:sharp-settings',
text: '设置',
},
],
},
],
},
}<template>
<FmPageLayout tabbar-name="tabbar2">
<!-- ... -->
</FmPageLayout>
</template>跳转路由地址
| 类型 | 默认值 | 说明 |
|---|---|---|
| string | / | 跳转路由地址 |
| 类型 | 默认值 | 说明 |
|---|---|---|
| string | / | 显示图标 |
该项配置最终会通过 <FmIcon /> 组件进行展示,意味着你可以使用自定义图标,也可使用 Iconify 提供的图标,详细可阅读《图标》。
| 类型 | 默认值 | 说明 |
|---|---|---|
| string | / | 激活时显示图标 |
该项配置最终会通过 <FmIcon /> 组件进行展示,意味着你可以使用自定义图标,也可使用 Iconify 提供的图标,详细可阅读《图标》。
| 类型 | 默认值 | 说明 |
|---|---|---|
| string | / | 显示文字 |
设置不同的类型值,展示效果也会不同。
boolean 展示形式为点,当值为 false 时隐藏number 展示形式为文本,当值小于等于 0 时隐藏string 展示形式为文本,当值为空时隐藏如果标记需要动态更新,请设置为箭头函数形式,并返回外部变量,例如搭配 pinia 一起使用。
badge: () => globalStore.number