search2.vue 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <uni-popup ref="searchPopup" type="top" :animation="false" :is-mask-click="true"
  3. mask-background-color="rgba(0, 0, 0, 0.4)">
  4. <view class="select-search-row">
  5. <view class="select-search-body">
  6. <input type="text" class="search-input" v-model="searchInput" placeholder="请输入课程名称" />
  7. <view class="search-icon" @click="handleSearch">
  8. <uni-icons type="search" size="24" color="#fff"></uni-icons>
  9. </view>
  10. </view>
  11. </view>
  12. </uni-popup>
  13. </template>
  14. <script setup>
  15. import { ref } from 'vue';
  16. const $emit = defineEmits(['search-btn'])
  17. const searchPopup = ref(null); // 索引
  18. const searchInput= ref('');
  19. // 打开弹窗
  20. function handleShow() {
  21. searchPopup.value.open();
  22. }
  23. // 取消
  24. function handleClose() {
  25. searchInput.value = '';
  26. searchPopup.value.close();
  27. }
  28. // 确认
  29. function handleSearch(){
  30. $emit('search-btn',searchInput);
  31. searchPopup.value.close();
  32. }
  33. defineExpose({
  34. handleShow,
  35. handleClose
  36. })
  37. </script>