naive-ui/demo/documentation/components/tree/enUS/multiple.demo.md
07akioni 487001d697 build: add changelog to site, refactor loader based on suffix
.demo.md for component demo
.demo-entry.md for demo entry
.md for common docs
2020-08-19 23:30:04 +08:00

885 B

Select Multiple Nodes

Set multiple to select multiple nodes.

<n-tree
  multiple
  block-node
  :data="data"
/>
<n-divider />
<n-tree
  multiple
  block-node
  :data="data"
  v-model="value"
/>
function createData (level = 4, baseKey = '') {
  if (!level) return undefined
  return Array
    .apply(null, { length: 6 - level })
    .map((_, index) => {
      const key = '' + baseKey + level + index
      return {
        label: createLabel(level),
        key,
        children: createData(level - 1, key)
      }
    })
}

function createLabel (level) {
  if (level === 4) return 'Out of Tao, One is born'
  if (level === 3) return 'Out of One, Two'
  if (level === 2) return 'Out of Two, Three'
  if (level === 1) return 'Out of Three, the created universe'
}

export default {
  data () {
    return {
      data: createData(),
      value: []
    }
  }
}