cascader.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="example-block" style="margin: 1rem">
  3. <span class="example-demonstration" style="margin: 1rem"
  4. >Child options expand when clicked (default)</span
  5. >
  6. <el-cascader v-model="value" :options="options" @change="handleChange" />
  7. </div>
  8. <div class="example-block">
  9. <span class="example-demonstration">Child options expand when hovered</span>
  10. <el-cascader
  11. v-model="value"
  12. :options="options"
  13. :props="props"
  14. @change="handleChange"
  15. />
  16. </div>
  17. </template>
  18. <script lang="ts" setup>
  19. import { ref } from 'vue'
  20. const value = ref([])
  21. const props = {
  22. expandTrigger: 'hover',
  23. }
  24. const handleChange = () => {
  25. // do nothing
  26. }
  27. const options = [
  28. {
  29. value: 'guide',
  30. label: 'Guide',
  31. children: [
  32. {
  33. value: 'disciplines',
  34. label: 'Disciplines',
  35. children: [
  36. {
  37. value: 'consistency',
  38. label: 'Consistency',
  39. },
  40. {
  41. value: 'feedback',
  42. label: 'Feedback',
  43. },
  44. {
  45. value: 'efficiency',
  46. label: 'Efficiency',
  47. },
  48. {
  49. value: 'controllability',
  50. label: 'Controllability',
  51. },
  52. ],
  53. },
  54. {
  55. value: 'navigation',
  56. label: 'Navigation',
  57. children: [
  58. {
  59. value: 'side nav',
  60. label: 'Side Navigation',
  61. },
  62. {
  63. value: 'top nav',
  64. label: 'Top Navigation',
  65. },
  66. ],
  67. },
  68. ],
  69. },
  70. {
  71. value: 'component',
  72. label: 'Component',
  73. children: [
  74. {
  75. value: 'basic',
  76. label: 'Basic',
  77. children: [
  78. {
  79. value: 'layout',
  80. label: 'Layout',
  81. },
  82. {
  83. value: 'color',
  84. label: 'Color',
  85. },
  86. {
  87. value: 'typography',
  88. label: 'Typography',
  89. },
  90. {
  91. value: 'icon',
  92. label: 'Icon',
  93. },
  94. {
  95. value: 'button',
  96. label: 'Button',
  97. },
  98. ],
  99. },
  100. {
  101. value: 'form',
  102. label: 'Form',
  103. children: [
  104. {
  105. value: 'radio',
  106. label: 'Radio',
  107. },
  108. {
  109. value: 'checkbox',
  110. label: 'Checkbox',
  111. },
  112. {
  113. value: 'input',
  114. label: 'Input',
  115. },
  116. {
  117. value: 'input-number',
  118. label: 'InputNumber',
  119. },
  120. {
  121. value: 'select',
  122. label: 'Select',
  123. },
  124. {
  125. value: 'cascader',
  126. label: 'Cascader',
  127. },
  128. {
  129. value: 'switch',
  130. label: 'Switch',
  131. },
  132. {
  133. value: 'slider',
  134. label: 'Slider',
  135. },
  136. {
  137. value: 'time-picker',
  138. label: 'TimePicker',
  139. },
  140. {
  141. value: 'date-picker',
  142. label: 'DatePicker',
  143. },
  144. {
  145. value: 'datetime-picker',
  146. label: 'DateTimePicker',
  147. },
  148. {
  149. value: 'upload',
  150. label: 'Upload',
  151. },
  152. {
  153. value: 'rate',
  154. label: 'Rate',
  155. },
  156. {
  157. value: 'form',
  158. label: 'Form',
  159. },
  160. ],
  161. },
  162. {
  163. value: 'data',
  164. label: 'Data',
  165. children: [
  166. {
  167. value: 'table',
  168. label: 'Table',
  169. },
  170. {
  171. value: 'tag',
  172. label: 'Tag',
  173. },
  174. {
  175. value: 'progress',
  176. label: 'Progress',
  177. },
  178. {
  179. value: 'tree',
  180. label: 'Tree',
  181. },
  182. {
  183. value: 'pagination',
  184. label: 'Pagination',
  185. },
  186. {
  187. value: 'badge',
  188. label: 'Badge',
  189. },
  190. ],
  191. },
  192. {
  193. value: 'notice',
  194. label: 'Notice',
  195. children: [
  196. {
  197. value: 'alert',
  198. label: 'Alert',
  199. },
  200. {
  201. value: 'loading',
  202. label: 'Loading',
  203. },
  204. {
  205. value: 'message',
  206. label: 'Message',
  207. },
  208. {
  209. value: 'message-box',
  210. label: 'MessageBox',
  211. },
  212. {
  213. value: 'notification',
  214. label: 'Notification',
  215. },
  216. ],
  217. },
  218. {
  219. value: 'navigation',
  220. label: 'Navigation',
  221. children: [
  222. {
  223. value: 'menu',
  224. label: 'Menu',
  225. },
  226. {
  227. value: 'tabs',
  228. label: 'Tabs',
  229. },
  230. {
  231. value: 'breadcrumb',
  232. label: 'Breadcrumb',
  233. },
  234. {
  235. value: 'dropdown',
  236. label: 'Dropdown',
  237. },
  238. {
  239. value: 'steps',
  240. label: 'Steps',
  241. },
  242. ],
  243. },
  244. {
  245. value: 'others',
  246. label: 'Others',
  247. children: [
  248. {
  249. value: 'dialog',
  250. label: 'Dialog',
  251. },
  252. {
  253. value: 'tooltip',
  254. label: 'Tooltip',
  255. },
  256. {
  257. value: 'popover',
  258. label: 'Popover',
  259. },
  260. {
  261. value: 'card',
  262. label: 'Card',
  263. },
  264. {
  265. value: 'carousel',
  266. label: 'Carousel',
  267. },
  268. {
  269. value: 'collapse',
  270. label: 'Collapse',
  271. },
  272. ],
  273. },
  274. ],
  275. },
  276. {
  277. value: 'resource',
  278. label: 'Resource',
  279. children: [
  280. {
  281. value: 'axure',
  282. label: 'Axure Components',
  283. },
  284. {
  285. value: 'sketch',
  286. label: 'Sketch Templates',
  287. },
  288. {
  289. value: 'docs',
  290. label: 'Design Documentation',
  291. },
  292. ],
  293. },
  294. ]
  295. </script>