nav-search-input.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="page">
  3. <swiper indicator-dots="true">
  4. <swiper-item v-for="(img, key) in imgUrls" :key="key"><image :src="img" /></swiper-item>
  5. </swiper>
  6. <view class="uni-padding-wrap uni-common-mt">
  7. <view class="uni-title">
  8. <view>本示例为导航栏带搜索框完整功能演示,主要演示有:</view>
  9. <view>1. 导航栏为 transparent 模式,向上滑动页面,导航栏会从透明变为实色。</view>
  10. <view>2. 点击搜索框跳转到搜索页面。</view>
  11. <view>3. 点击导航栏右侧按钮实现关联操作。</view>
  12. <view>4. 搜索页面为提示词搜索,输入内容实时显示关联词。</view>
  13. <view>5. 搜索结果根据搜索内容高亮显示文字。</view>
  14. <view>6. 点击搜索列表或者软键盘搜索按钮,会将结果保存到搜索历史列表。</view>
  15. <view>7. 点击删除图标,清空历史搜索列表。</view>
  16. <view>Tips </view>
  17. <view>1. 本示例目前仅支持 App 端</view>
  18. <view>2. 所有示例均为演示使用,具体逻辑需要自己实现。</view>
  19. </view>
  20. </view>
  21. <view style="height: 1000rpx;"></view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. showSwiper: false,
  29. imgUrls: [
  30. 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b4b60b10-5168-11eb-bd01-97bc1429a9ff.jpg',
  31. 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b1dcfa70-5168-11eb-bd01-97bc1429a9ff.jpg'
  32. ]
  33. };
  34. },
  35. /**
  36. * 当 searchInput 配置 disabled 为 true 时触发
  37. */
  38. onNavigationBarSearchInputClicked(e) {
  39. console.log('事件执行了')
  40. uni.navigateTo({
  41. url: '/pages/template/nav-search-input/detail/detail'
  42. });
  43. },
  44. /**
  45. * 点击导航栏 buttons 时触发
  46. */
  47. onNavigationBarButtonTap() {
  48. uni.showModal({
  49. title: '提示',
  50. content: '用户点击了功能按钮,这里仅做展示。',
  51. success: res => {
  52. if (res.confirm) {
  53. console.log('用户点击了确定');
  54. }
  55. }
  56. });
  57. }
  58. };
  59. </script>
  60. <style>
  61. image,
  62. swiper,
  63. .img-view {
  64. width: 750rpx;
  65. width: 100%;
  66. height: 500rpx;
  67. }
  68. .page-section-title {
  69. margin-top: 50rpx;
  70. }
  71. </style>