index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { defineComponent, toRefs, reactive, onMounted, ref, watch } from 'vue'
  2. import { ElTag } from 'element-plus'
  3. import classes from './index.module.less'
  4. export default defineComponent({
  5. name: 'tagItem',
  6. emits: ['searchTag'],
  7. props: {
  8. title: {
  9. type: String,
  10. default: ''
  11. },
  12. isChiose: {
  13. type: Boolean,
  14. default: false
  15. },
  16. item: {
  17. type: Object,
  18. default: { isCheck: false }
  19. },
  20. isSmall: {
  21. type: Boolean,
  22. default: false
  23. }
  24. },
  25. setup(props, conent) {
  26. const state = reactive({
  27. title: props.title,
  28. isCheck: props.item.isCheck,
  29. isSmall: props.isSmall
  30. })
  31. const shioseTag = (key: string) => {
  32. conent.emit('searchTag', key)
  33. }
  34. watch(
  35. () => props.item,
  36. item => {
  37. state.isCheck = item.isCheck
  38. },
  39. {
  40. deep: true
  41. }
  42. )
  43. const checkDrak = () => {
  44. if (props.isChiose) {
  45. state.isCheck = true
  46. }
  47. }
  48. return () => (
  49. <>
  50. {/* effect={state.isCheck ? 'dark' : 'light'} */}
  51. <div
  52. onClick={() => shioseTag(state.title)}
  53. class={[classes.tag, state.isSmall ? classes.small : '']}
  54. >
  55. {state.title}
  56. </div>
  57. </>
  58. )
  59. }
  60. })