Appearance
BVerticalLayout #
用于提供通用型垂直布局
组件注册 #
js
import { BVerticalLayout } from '@fesjs/traction-widget';
app.use(BVerticalLayout);
代码演示 #
基础用法 #
传入菜单列表数据,自动生成顶部为菜单栏的水平布局
Play
<template>
<div style="height: 500px">
<BVerticalLayout v-model:curPath="currentPath" :menus="menus" @menuChange="onMenuClick">
<template v-slot:logo>
logo
</template>
<template v-slot:exElement>
<FInput placeholder="请输入">
<template #suffix>
<SearchOutlined @click="search" />
</template>
</FInput>
</template>
<template v-slot:userInfo>
<span class="user-name">管理员(admin)</span>
<FDivider vertical></FDivider>
<a
class="logout"
href="javascript:void(0)"
@click="handleLogout"
>退出</a>
</template>
<template v-slot:container>
<div>
下方容器内容使用slot插槽,
当前选择菜单路径:{{currentPath}}
</div>
</template>
</BVerticalLayout>
</div>
</template>
<script setup lang="ts">
import { BVerticalLayout } from '@fesjs/traction-widget';
import { FDivider, FInput } from '@fesjs/fes-design';
import { ref, h} from 'vue';
import { AppstoreOutlined, DateOutlined,ClusterOutlined, SettingOutlined, SearchOutlined } from '@fesjs/fes-design/icon';
const currentPath = ref<string>('/rules/template1');
const menus = ref([
{
label: '规则模板1',
value: '/rules/template1',
icon: () => h(ClusterOutlined),
},
{
label: '规则模板2',
value: '/rules/template2',
icon: () => h(ClusterOutlined),
},
{
label: '规则模板3',
value: '/rules/template3',
icon: () => h(ClusterOutlined),
children: [{
label: '规则查询一个很长想看下省略效果的标题2',
value: '/rules/template3/query',
icon: () => h(DateOutlined),
}, {
label: '规则模板2',
value: '/rules/template3/template',
icon: () => h(ClusterOutlined),
}]
},{
label: '任务查询1',
value: '/tasks',
icon: () => h(AppstoreOutlined),
children: [{
label: '规则查询一个很长想看下省略效果的标题2',
value: '/tasks/query',
icon: () => h(DateOutlined),
}, {
label: '规则模板2',
value: '/tasks/template',
icon: () => h(ClusterOutlined),
}]
}])
const search = () => {
console.log('查询');
}
const handleLogout = () => {
console.log('退出登录');
}
const onMenuClick = (v: any) => {
currentPath.value = v.value;
console.log('onMenuClick-菜单跳转', currentPath.value);
};
</script>
<style scoped>
.user-name {
white-space: nowrap;
}
.logout {
white-space: nowrap;
color: #63656f;
}
</style>查看代码
参数说明 #
BVerticalLayout Props #
| 属性 | 说明 | 类型 | 默认值 | 是否必须 |
|---|---|---|---|---|
| curPath | 当前路径 | String | '' | 是 |
| menus | 菜单列表 | Array(object) | [] | 是 |
| position | 菜单位置,可选值left、right | String | 'left' | 是 |
BVerticalLayout Events #
| 事件名称 | 说明 | 回调参数 |
|---|---|---|
| menuChange | 菜单切换时触发的回调函数 | 当前菜单路径值 |
BVerticalLayout Slots #
| 名称 | 说明 | 参数 |
|---|---|---|
| logo | 顶部菜单左侧logo内容 | - |
| exElement | 顶部菜单右侧可追加额外内容 | - |
| userInfo | 用户信息 | - |
| container | 布局下方主要内容 | - |