index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="search adfac">
  3. <image class="icon" src="https://oss.familydaf.cn/sxsnfile/20251218/9093140778f4463489a7e83746b70ab2.png"></image>
  4. <view class="input">
  5. <up-input :placeholder="placeholder" v-model="keyword" border="none" style="font-size: 26rpx;" @confirm="handleSearch"></up-input>
  6. </view>
  7. <view class="btn" @click="handleSearch" v-if="!isCancel">搜索</view>
  8. <view class="btn" @click="handleCancel" v-else>取消</view>
  9. </view>
  10. </template>
  11. <script setup name="CusSearch">
  12. defineProps({
  13. placeholder:{
  14. typeof: String,
  15. default: '查找公益活动'
  16. },
  17. isCancel:{
  18. typeof: Boolean,
  19. default: false
  20. }
  21. })
  22. import { ref, onMounted } from 'vue'
  23. const keyword = ref('')
  24. const emits = defineEmits(['handleSearch','handleCancel'])
  25. const handleSearch = () => {
  26. emits('handleSearch',keyword.value);
  27. }
  28. const handleCancel = () => {
  29. emits('handleCancel');
  30. }
  31. defineExpose({
  32. keyword
  33. })
  34. </script>
  35. <style scoped lang="scss">
  36. ::v-deep .u-input__content input{
  37. // 解决输入框在ios机型上获取不到闪烁的光标的问题(安卓机型上有)
  38. /* 1. (首选方案) 强制开启硬件加速,触发独立渲染层,修复iOS下的渲染bug */
  39. transform: translateZ(0);
  40. -webkit-transform: translateZ(0);
  41. /* 2. (辅助方案) 明确指定文本可选,有时有助于唤醒光标 */
  42. -webkit-user-select: text;
  43. user-select: text;
  44. /* 3. (保持) 您已正确设置,确保光标颜色正确 */
  45. caret-color: #252525 !important;
  46. }
  47. .search{
  48. width: 100%;
  49. background: #FFFFFF;
  50. border-radius: 34rpx;
  51. padding: 6rpx 6rpx 6rpx 26rpx;
  52. box-sizing: border-box;
  53. .icon{
  54. width: 36rpx;
  55. height: 36rpx;
  56. }
  57. .input{
  58. flex: 1;
  59. padding: 0 11rpx;
  60. box-sizing: border-box;
  61. }
  62. .btn{
  63. padding: 9rpx 27rpx;
  64. background: #B7F358;
  65. border-radius: 34rpx;
  66. font-family: PingFangSC, PingFang SC;
  67. font-weight: 400;
  68. font-size: 26rpx;
  69. color: #252525;
  70. line-height: 37rpx;
  71. }
  72. }
  73. </style>