0.1.1 • Published 5 years ago

simter-vue-tree v0.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

simter-vue-tree

A vue tree component. Demo.

Requirement

NameVersion
Vue2.5+
Parcel1.10+

Develop

yarn install
yarn start

Then visit http://localhost:1234.

Build

yarn run build

Use rollup build component to dist directory. Use parcel build demo to docs/demo directory.

Props

NameRequireValueTypeDescription
nodestrue[{}][String]FunctionDefine tree nodes.- Array : The child nodes, String array item means setting the label property- Function : return a array or Promise resolve with the child nodes, the first param is the parent node object
├ labeltrueStringFunctionThe node's visible text. It's the string value or the function return value. The function's first param is the node object
├ iconfalseStringThe node's icon class
├ ...customfalseCustomThe custom properties for this node
├ nodesfalse[{}]FunctionThe nested nodes
parentNodefalseNodeThe parent node that this tree belong to
classesfalse{}Define inner dom elements global classes
├ hoverfalseStringThe class to add when hover on the node
├ activefalseStringThe class to add when the node is active
├ treefalseStringThe extra tree class to add
├ nodefalseStringThe extra node class to add
├ wrapperfalseStringThe extra node wrapper class to add
├ togglefalseStringThe extra toggle class to add
├ iconfalseStringThe extra icon class to add
├ labelfalseStringThe extra label class to add
├ collapsedfalseStringThe folder's collapsed class
├ expandedfalseStringThe folder's expanded class

Events

NameParamsDescription
click-nodenodeemit when use click the node

Html Structure

<ul class="st-tree">
  <!-- folder node -->
  <li class="st-node">
    <div class="st-wrapper">
      <span class="st-toggle"></span>
      <span class="st-icon"></span>
      <span class="st-label">Node 1</span>
    </div>
    <ul class="st-tree">
      <!-- leaf node -->
      <li class="st-node">
        <div class="st-wrapper">
          <span class="st-toggle"></span>
          <span class="st-icon"></span>
          <span class="st-label">Node 1-1</span>
        </div>
      </li>
      ...
    </ul>
  </li>
  <!-- leaf node -->
  <li class="st-node">
    <div class="st-wrapper">
      <span class="st-toggle"></span>
      <span class="st-icon"></span>
      <span class="st-label">Node 2</span>
    </div>
  </li>
  ...
</ul>