friend-search.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <view class="page friend-search" >
  3. <view>
  4. <uni-search-bar v-model="searchText" :focus="true" @cancel="onCancel()" placeholder="输入好友昵称搜索"></uni-search-bar>
  5. </view>
  6. <view class="friend-items">
  7. <scroll-view class="scroll-bar" scroll-with-animation="true" scroll-y="true">
  8. <view v-for="(friend,index) in $store.state.friendStore.friends" v-show="searchText && friend.nickName.startsWith(searchText)" :key="index">
  9. <friend-item :friend="friend" :index="index"></friend-item>
  10. </view>
  11. </scroll-view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. searchText:""
  20. }
  21. },
  22. methods: {
  23. onCancel(){
  24. uni.navigateBack();
  25. }
  26. }
  27. }
  28. </script>
  29. <style scoped lang="scss">
  30. .friend-search {
  31. position: relative;
  32. border: #dddddd solid 1px;
  33. display: flex;
  34. flex-direction: column;
  35. .search-bar {
  36. background: white;
  37. }
  38. .friend-items{
  39. position: relative;
  40. flex: 1;
  41. overflow: hidden;
  42. .scroll-bar {
  43. height: 100%;
  44. }
  45. }
  46. }
  47. </style>