You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
817 B

1 month ago
  1. <template>
  2. <view class="content">
  3. <uni-calendar class="uni-calendar--hook" :selected="info.selected" :showMonth="false" @change="change"
  4. @monthSwitch="monthSwitch" />
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. info: {
  12. lunar: true,
  13. range: true,
  14. insert: false,
  15. selected: []
  16. }
  17. };
  18. },
  19. methods: {
  20. change(e) {
  21. console.log('change 返回:', e)
  22. // 选中日期
  23. const selectedValue = this.info.selected.find(item => item.date === e.fulldate)
  24. if (selectedValue) {
  25. // 存在则移除
  26. this.info.selected = this.info.selected.filter(item => item.date !== e.fulldate);
  27. } else {
  28. this.info.selected.push({
  29. date: e.fulldate,
  30. info: '选中'
  31. })
  32. }
  33. console.log(this.info.selected)
  34. },
  35. }
  36. };
  37. </script>