展品维保小程序前端代码接口
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.

157 lines
3.3 KiB

2 weeks ago
  1. <template>
  2. <view class="demo-container">
  3. <view class="demo-title">搜索组件演示</view>
  4. <!-- 基础搜索框 -->
  5. <view class="demo-section">
  6. <view class="section-title">基础搜索框</view>
  7. <Search
  8. v-model="searchValue1"
  9. placeholder="请输入搜索内容"
  10. @search="onSearch"
  11. @clear="onClear"
  12. @clickIcon="onClickIcon"
  13. />
  14. <view class="result">搜索内容{{ searchValue1 }}</view>
  15. </view>
  16. <!-- 右侧搜索图标 -->
  17. <view class="demo-section">
  18. <view class="section-title">右侧搜索图标</view>
  19. <Search
  20. v-model="searchValue2"
  21. placeholder="搜索图标在右侧"
  22. searchIconAlign="right"
  23. @search="onSearch"
  24. />
  25. </view>
  26. <!-- 居中对齐 -->
  27. <view class="demo-section">
  28. <view class="section-title">居中对齐</view>
  29. <Search
  30. v-model="searchValue3"
  31. placeholder="居中对齐的搜索框"
  32. textAlign="center"
  33. :showIcon="false"
  34. @search="onSearch"
  35. />
  36. </view>
  37. <!-- 自定义样式 -->
  38. <!-- <view class="demo-section"> -->
  39. <view class="section-title">自定义样式</view>
  40. <Search
  41. v-model="searchValue4"
  42. placeholder="自定义背景色和高度"
  43. :placeholderClass="{
  44. color:'red',
  45. fontSize:'24rpx'
  46. }"
  47. bgColor="#e8f4fd"
  48. height="100rpx"
  49. :showCancel="false"
  50. @search="onSearch"
  51. />
  52. <!-- </view> -->
  53. <!-- 禁用状态 -->
  54. <view class="demo-section">
  55. <view class="section-title">禁用状态</view>
  56. <Search
  57. v-model="searchValue5"
  58. placeholder="禁用状态的搜索框"
  59. :disabled="true"
  60. />
  61. </view>
  62. <!-- 不显示取消按钮 -->
  63. <view class="demo-section">
  64. <view class="section-title">不显示取消按钮</view>
  65. <Search
  66. v-model="searchValue6"
  67. placeholder="没有取消按钮"
  68. :showCancel="false"
  69. @search="onSearch"
  70. />
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import Search from '@/pages/components/Search.vue'
  76. export default {
  77. components: {
  78. Search
  79. },
  80. data() {
  81. return {
  82. searchValue1: '',
  83. searchValue2: '',
  84. searchValue3: '',
  85. searchValue4: '',
  86. searchValue5: '禁用状态示例',
  87. searchValue6: ''
  88. }
  89. },
  90. methods: {
  91. onSearch(value) {
  92. uni.showToast({
  93. title: `搜索:${value}`,
  94. icon: 'none'
  95. })
  96. },
  97. onClear() {
  98. uni.showToast({
  99. title: '清除搜索内容',
  100. icon: 'none'
  101. })
  102. },
  103. onClickIcon() {
  104. uni.showToast({
  105. title: '点击了搜索图标',
  106. icon: 'none'
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .demo-container {
  114. padding: 40rpx;
  115. background-color: #f5f5f5;
  116. min-height: 100vh;
  117. }
  118. .demo-title {
  119. font-size: 36rpx;
  120. font-weight: bold;
  121. text-align: center;
  122. margin-bottom: 40rpx;
  123. color: #333;
  124. }
  125. .demo-section {
  126. margin-bottom: 40rpx;
  127. background-color: #fff;
  128. border-radius: 20rpx;
  129. overflow: hidden;
  130. }
  131. .section-title {
  132. padding: 30rpx;
  133. font-size: 28rpx;
  134. font-weight: bold;
  135. color: #333;
  136. background-color: #f8f9fa;
  137. border-bottom: 1px solid #eee;
  138. }
  139. .result {
  140. padding: 20rpx 30rpx;
  141. font-size: 24rpx;
  142. color: #666;
  143. background-color: #f8f9fa;
  144. }
  145. </style>