form-branch.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div>
  3. <p
  4. v-if="props.title"
  5. class="card-title"
  6. >
  7. {{ props.title }}
  8. </p>
  9. <div
  10. v-for="(item, index) in props.list"
  11. :key="index"
  12. class="form-branch-item"
  13. @click="listItemClick(item)"
  14. >
  15. {{ item.content }}
  16. </div>
  17. </div>
  18. </template>
  19. <script lang="ts">
  20. interface branchItem {
  21. content: string;
  22. desc: string;
  23. }
  24. interface Props {
  25. title: string;
  26. list: Array<branchItem>;
  27. }
  28. export default {
  29. props: {
  30. title: {
  31. type: String,
  32. default: '',
  33. },
  34. list: {
  35. type: Array,
  36. default: () => ([]),
  37. },
  38. },
  39. emits: ['input-click'],
  40. setup(props: Props, { emit }) {
  41. const listItemClick = (branch: branchItem): void => {
  42. emit('input-click', branch);
  43. };
  44. return {
  45. props,
  46. listItemClick,
  47. };
  48. },
  49. };
  50. </script>
  51. <style lang="scss">
  52. .card-title {
  53. margin-bottom: 8px;
  54. }
  55. .form-branch-item {
  56. font-weight: 400;
  57. color: rgba(54, 141, 255, 1);
  58. padding-top: 5px;
  59. cursor: pointer;
  60. padding-bottom: 5px;
  61. }
  62. </style>