treeSelect 显示不全问题__插件包treeselete

1.功能

  • 支持嵌套选项的单选和多选;
  • 模糊匹配;
  • 异步搜索;
  • 延迟加载(仅在需要时加载深度选项的数据);
  • 键盘支持;
  • 丰富的选项和高度可定制的;
  • 支持多种浏览器。

 2.使用

npm install --save @riophae/vue-treeselect

<template>
  <div id="app">
    <treeselect v-model="value" :multiple="true" :options="options" />
  <treeselect
                v-model="form.deptId"
                :options="deptOptions"
                :show-count="true"
                placeholder="请选择"
              >
                <label
                  slot="option-label"
                  slot-scope="{ node, shouldShowCount, count,countClassName, labelClassName }"
                  :class="labelClassName"
                  :title="node.label"
                >{{ node.label }}</label>
              </treeselect>
  </div>
</template>

<script>
  // import the component
  import Treeselect from '@riophae/vue-treeselect'
  // import the styles
  import '@riophae/vue-treeselect/dist/vue-treeselect.css'

  export default {
    // register the component
    components: { Treeselect },
    data() {
      return {
        // define the default value
        value: null,
        // define options
        options: [ {
          id: 'a',
          label: 'a',
          children: [ {
            id: 'aa',
            label: 'aa',
          }, {
            id: 'ab',
            label: 'ab',
          } ],
        }, {
          id: 'b',
          label: 'b',
        }, {
          id: 'c',
          label: 'c',
        } ],
      }
    },
  }
</script>

3.配置

Props

NameType / DefaultDescription
allowClearingDisabledType: Boolean
Default: false
Whether to allow resetting value even if there are disabled selected nodes.
allowSelectingDisabledDescendantsType: Boolean
Default: false
When an ancestor node is selected/deselected, whether its disabled descendants should be selected/deselected. You may want to use this in conjunction with allowClearingDisabled prop.
alwaysOpenType: Boolean
Default: false
Whether the menu should be always open.
appendToBodyType: Boolean
Default: false
Append the menu to <body />.
asyncType: Boolean
Default: false
Whether to enable async search mode.
autoFocusType: Boolean
Default: false
Automatically focus the component on mount.
autoLoadRootOptionsType: Boolean
Default: true
Automatically load root options on mount. When set to false, root options will be loaded when the menu is opened.
autoDeselectAncestorsType: Boolean
Default: false
When user deselects a node, automatically deselect its ancestors. Applies to flat mode only.
autoDeselectDescendantsType: Boolean
Default: false
When user deselects a node, automatically deselect its descendants. Applies to flat mode only.
autoSelectAncestorsType: Boolean
Default: false
When user selects a node, automatically select its ancestors. Applies to flat mode only.
autoSelectDescendantsType: Boolean
Default: false
When user selects a node, automatically select its descendants. Applies to flat mode only.
backspaceRemovesType: Boolean
Default: true
Whether Backspace removes the last item if there is no text input.
beforeClearAllType: Fn() 🡒 (Boolean | Promise<Boolean>)
Default: () => true
Function that processes before clearing all input fields. Return false to stop values being cleared.
branchNodesFirstType: Boolean
Default: false
Show branch nodes before leaf nodes.
cacheOptionsType: Boolean
Default: true
Whether to cache results of each search request for async search mode.
clearableType: Boolean
Default: true
Whether to show an "×" button that resets value.
clearAllTextType: String
Default: "Clear all"
Title for the "×" button when :multiple="true".
clearOnSelectType: Boolean
Default: Defaults to false when :multiple="true"; always true otherwise.
Whether to clear the search input after selecting an option. Use only when :multiple="true". For single-select mode, it always clears the input after selecting regardless of the prop value.
clearValueTextType: String
Default: "Clear value"
Title for the "×" button.
closeOnSelectType: Boolean
Default: true
Whether to close the menu after selecting an option. Use only when :multiple="true".
defaultExpandLevelType: Number
Default: 0
How many levels of branch nodes should be automatically expanded when loaded. Set Infinity to make all branch nodes expanded by default.
defaultOptionsType: Boolean | node[]
Default: false
The default set of options to show before the user starts searching. Used for async search mode. When set to true, the results for search query as a empty string will be autoloaded.
deleteRemovesType: Boolean
Default: true
Whether Delete removes the last item if there is no text input.
delimiterType: String
Default: ","
Delimiter to use to join multiple values for the hidden field value.
flattenSearchResultsType: Boolean
Default: false
Whether to flatten the tree when searching (sync search mode only). See here for example.
disableBranchNodesType: Boolean
Default: false
Whether to prevent branch nodes from being selected. See here for example.
disabledType: Boolean
Default: false
Whether to disable the control or not.
disableFuzzyMatchingType: Boolean
Default: false
Set to true to disable the fuzzy matching functionality, which is enabled by default.
flatType: Boolean
Default: false
Whether to enable flat mode or not. See here for detailed information.
instanceIdType: String | Number
Default: "<auto-incrementing number>$$"
Will be passed with all events as the last param. Useful for identifying events origin.
joinValuesType: Boolean
Default: false
Joins multiple values into a single form field with the delimiter (legacy mode).
limitType: Number
Default: Infinity
Limit the display of selected options. The rest will be hidden within the limitText string.
limitTextType: Fn(count) 🡒 String
Default: count => `and ${count} more`
Function that processes the message shown when selected elements pass the defined limit.
loadingTextType: String
Default: "Loading..."
Text displayed when loading options.
loadOptionsType: Fn({actioncallbackparentNode?instanceId}) 🡒 (void | Promise)
Default: 
Used for dynamically loading options. See here for detailed information.
Possible values of action"LOAD_ROOT_OPTIONS""LOAD_CHILDREN_OPTIONS" or "ASYNC_SEARCH".
callback - a function that accepts an optional error argument
parentNode - only presents when loading children options
searchQuery - only presents when searching async options
instanceId - eqauls to the value of instanceId prop you passed to vue-treeselect
matchKeysType: String[]
Default: [ "label" ]
Which keys of a node object to filter on.
maxHeightType: Number
Default: 300
Sets maxHeight style value of the menu.
multipleType: Boolean
Default: false
Set true to allow selecting multiple options (a.k.a., multi-select mode).
nameType: String
Default: 
Generates a hidden <input /> tag with this field name for html forms.
noChildrenTextType: String
Default: "No sub-options."
Text displayed when a branch node has no children.
noOptionsTextType: String
Default: "No options available."
Text displayed when there are no available options.
noResultsTextType: String
Default: "No results found..."
Text displayed when there are no matching search results.
normalizerType: Fn(nodeinstanceId) 🡒 node
Default: node => node
Used for normalizing source data. See here for detailed information.
openDirectionType: String
Default: "auto"
By default ("auto"), the menu will open below the control. If there is not enough space, vue-treeselect will automatically flip the menu. You can use one of other four options to force the menu to be always opened to specified direction.
Acceptable values: "auto""below""bottom""above" or "top".
openOnClickType: Boolean
Default: true
Whether to automatically open the menu when the control is clicked.
openOnFocusType: Boolean
Default: false
Whether to automatically open the menu when the control is focused.
optionsType: node[]
Default: 
Array of available options. See here to learn how to define them.
placeholderType: String
Default: "Select..."
Field placeholder, displayed when there's no value.
requiredType: Boolean
Default: false
Applies HTML5 required attribute when needed.
retryTextType: String
Default: "Retry?"
Text displayed asking user whether to retry loading children options.
retryTitleType: String
Default: "Click to retry"
Title for the retry button.
searchableType: Boolean
Default: true
Whether to enable searching feature or not.
searchNestedType: Boolean
Default: false
Set true if the search query should search in all ancestor nodes too. See here for example.
searchPromptTextType: String
Default: "Type to search..."
Text tip to prompt for async search. Used for async search mode.
showCountType: Boolean
Default: false
Whether to show a children count next to the label of each branch node. See here for example.
showCountOfType: String
Default: "ALL_CHILDREN"
Used in conjunction with showCount to specify which type of count number should be displayed.
Acceptable values: "ALL_CHILDREN""ALL_DESCENDANTS""LEAF_CHILDREN" or "LEAF_DESCENDANTS".
showCountOnSearchType: Boolean
Default: 
Whether to show children count when searching. Fallbacks to the value of showCount when not specified.
sortValueByType: String
Default: "ORDER_SELECTED"
In which order the selected options should be displayed in trigger & sorted in value array. Use only when :multiple="true". See here for example.
Acceptable values: "ORDER_SELECTED""LEVEL" or "INDEX".
tabIndexType: Number
Default: 0
Tab index of the control.
valueType: id | node | id[] | node[]
Default: 
The value of the control.
Should be id or node object when :multiple="false", or an array of id or node object when :multiple="true". Its format depends on the valueFormat prop.
For most cases, just use v-model instead.
valueConsistsOfType: String
Default: "BRANCH_PRIORITY"
Which kind of nodes should be included in the value array in multi-select mode. See here for example.
Acceptable values: "ALL""BRANCH_PRIORITY""LEAF_PRIORITY" or "ALL_WITH_INDETERMINATE".
valueFormatType: String
Default: "id"
Format of value prop.
Note that, when set to "object", only id & label properties are required in each node object in value.
Acceptable values: "id" or "object".
zIndexType: Number | String
Default: 999
z-index of the menu.

Events

NameAttributesDescription
open(instanceId)Emitted when the menu opens.
close(valueinstanceId)Emitted when the menu closes.
input(valueinstanceId)Emitted after value changes.
select(nodeinstanceId)Emitted after selecting an option.
deselect(nodeinstanceId)Emitted after deselecting an option.
search-change(searchQueryinstanceId)Emitted after the search query changes.

Slots

NamePropsDescription
option-label{nodeshouldShowCountcountlabelClassNamecountClassName}Slot for custom option label template. See here for detailed information.
value-label{node}Slot for custom value label template. See here for detailed information.
before-list-Slot showed before the menu list.
after-list-Slot showed after the menu list.

官网

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值