naive-ui/demo/documentation/components/tree/enUS/basic.md
2019-10-25 12:59:50 +08:00

466 B

Basic

<n-tree
  :data="data"
  checkable
/>
let key = 0

function genData (layer = 4, depth = 0, prefix = '') {
  if (layer === depth) return
  const data = []
  const count = 4
  for (let i = 0; i < count; ++i) {
    data.push({
      label: `${prefix}_${i}`,
      key: key++,
      children: genData(layer, depth + 1, `${prefix}_${i}`)
    })
  }
  return data
}

export default {
  data () {
    return {
      data: genData()
    }
  }
}