Skip to content

vue
<div style="position: relative; width: 100%; height: 800px; display: flex;">
    <fv-NavigationView :options="options"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+View" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>

vue
<div style="position: relative; width: 100%; height: 800px; display: flex;">
    <fv-NavigationView :options="options" expandMode="flyout"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+View" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>

vue
<div style="position: relative; width: 100%; height: 800px; display: flex;">
    <fv-NavigationView :options="options" mobileDisplay="100000000" flyoutDisplay="500"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+Panel" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>

  1. Standard
vue
<div style="position: relative; width: 100%; height: 800px; background: black; display: flex;">
    <fv-NavigationView :options="options" theme="dark"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+Panel" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>
  1. Flyout
vue
<div style="position: relative; width: 100%; height: 800px; background: black; display: flex;">
    <fv-NavigationView :options="options" expandMode="flyout" theme="dark"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+Panel" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>
  1. Mobile
vue
<div style="position: relative; width: 100%; height: 800px; background: black; display: flex;">
    <fv-NavigationView :options="options" mobileDisplay="100000000" flyoutDisplay="500" theme="dark"></fv-NavigationView>
    <fv-img src="https://placehold.co/1280x720/png?text=VFluent+Navigation+Panel" style="width: 350px; height: 100%; flex: 1;"></fv-img>
</div>

属性


属性类型必填默认值说明
modelValueobject{}当前选中项,用v-model绑定。
optionsarray[]选项数据,参照ListView中的items数据格式。
titlestring'NavigationView'NavigationView 标题。
expandbooleantrue初始是否展开,可通过 sync 方法来同步状态。
expandModestring'relative'展开模式,有占位和浮动两种。
expandWidthnumber350展开宽度,以px为单位。
expandDisplaynumber1024浏览器宽度大于多少时展开。
compactWidthnumber46折叠宽度,以px为单位。
flyoutDisplaynumber0浏览器宽度小于多少时开启浮动模式,若expandMode设为flyout,则始终为浮动模式。
fullSizeDisplaynumber800浏览器宽度小于多少时全屏显示。
mobileDisplaynumber0浏览器宽度小于多少时开启移动端模式。
showBackbooleantrue是否显示后退按钮。
showSearchbooleantrue是否显示搜索框。
settingTitlestring'Settings'设置选项的标题。
showSettingbooleantrue是否显示设置选项。
searchPlaceholderstring'Search'搜索框的占位符。
foregroundstring''NavigationView 前景色。
backgroundstring''NavigationView 背景色。
themestring'global'主题样式。支持 globallightdarksystemcustom
emitsarray[ 'update:modelValue', 'expand-change', 'setting-click', 'item-click', 'back', 'expand-click', 'update:expand' ]参见组件的 emits 选项。
showNavbooleantrue参见组件的 showNav 选项。
disabledbooleanfalse参见组件的 disabled 选项。
langstring"global"参见组件的 lang 选项。

事件


事件名参数说明
item-clickobject选项点击后触发。
setting-clickObject设置选项被点击后触发事件,返回{ event: MouseEvent }
update:expandboolean当折叠或展开时同步外界传入的expand
expand-changeboolean当折叠或展开时触发事件并提供当前状态。
expand-click
backMouseEvent返回选项被点击后触发事件。

插槽


  1. ListItem

默认以value中每一项的属性name作为默认显示, 参考ListView, 包含以下可选属性

  • item: 当前项
  • index: 当前项索引
vue
<template v-slot:listItem="x">
    <i v-show="x.valueTrigger(x.item.icon) !== undefined" class="ms-Icon icon" :class="[`ms-Icon--${x.valueTrigger(x.item.icon)}`]"></i>
    <p class="name" :style="{ color: x.valueTrigger(x.item.type) == 'header' ? foreground : ''}">{{x.valueTrigger(x.item.name)}}</p>
</template>

注意在收缩时要隐藏<p>标签的话一定要将其类型加上name.

  1. NavIcon

默认的导航按钮为GlobalNavButton图标

vue
<template v-slot:navIcon>
    <i class="ms-Icon ms-Icon--GlobalNavButton icon"></i>
</template>
  1. BackIcon

默认的后退按钮为Back图标

vue
<template v-slot:backIcon>
    <i class="ms-Icon ms-Icon--Back icon"></i>
</template>
  1. Title

默认的标题为title属性值

vue
<template v-slot:title="{ show }">
    <p v-show="show" class="name title">{{ title }}</p>
</template>
  1. Banner

自定义NavigationView顶部banner区域内容, 可用于自定义logo等

vue
<template v-slot:banner>
    <div class="banner">
        <img src="https://placehold.co/200x300/png?text=Logo" alt="logo" />
    </div>
</template>
  1. Setting

自定义设置项区域内容。

vue
<template v-slot:setting>
    <fv-animated-icon 
        v-show="showSetting"
        ref="setting"
        modelValue="bounceRotate"
        class="fv-nav-default-item"
        :hideContent="!thisExpand"
        style="width: calc(100% - 10px)"
        @click="settingClick({ event: $event })"
    >
        <i class="ms-Icon ms-Icon--Settings icon"></i>
        <template v-slot:content>
            <p class="name">{{ settingTitle }}</p>
        </template>
    </fv-animated-icon>
</template>
  1. Mask

自定义组件遮罩层内容,可用于全局加载等场景。

vue
<fv-NavigationView :options="options">
    <template v-slot:mask>
        <div
            style="
                position: absolute;
                inset: 0;
                display: flex;
                align-items: center;
                justify-content: center;
                background: rgba(0, 0, 0, 0.35);
                color: white;
                z-index: 10;
            "
        >
            加载中...
        </div>
    </template>
</fv-NavigationView>

Data


  1. options
  • 数据格式参考ListViewitems的形式, 其中key字段建议开发者在有重复名称和类型字段时声明用来区别项目
  • 开发者可利用icon字段来应用Fabric Icon
javascript
options = [{ key: "", name: "", type: "", icon: "", disabled: "" }];

//e.g.//

options: [
    { key: 0, name: "Fruits", type: "header"},
    { key: 1, name: "Apple", icon: "WindowsLogo"},
    { key: 2, name: "Banana", icon: "DelveAnalyticsLogo"},
    { key: 3, name: "Orange", icon: "Guitar"},
    { key: 4, name: "Grape", icon: "HailDay"},
    { key: 5, name: "", type: "divider" },
    { key: 6, name: "Vegetables", type: "header"},
    { key: 7, name: "Broccoli", icon: "QuadColumn"},
    { key: 8, name: "Carrot", icon: "Quantity"},
    { key: 9, name: "Lettuce", icon: "TestBeaker"}
];

Appendix


  1. NavigationView中的setting项由于不包含在options中, 故无法在options中找到setting项. 但是当选中setting项时, value值会改变为{ name: ">setting", type: "setting" }, 你也可以通过在外部赋值的方式将当前选项更改为setting项.

特别地 0.1.54版本后支持采用函数式字段, 其中支持的字段包括name, disabled, choosen, type, icon, show

MIT Licensed