瀏覽代碼

输入内容双向绑定

lifanagju_citu 8 月之前
父節點
當前提交
9b64185c46
共有 1 個文件被更改,包括 7 次插入8 次删除
  1. 7 8
      pages/index/position.vue

+ 7 - 8
pages/index/position.vue

@@ -3,6 +3,7 @@
     <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" @refresherrefresh="refresh" style="position:relative;">
       <view class="white-bgc">
         <uni-search-bar
+          v-model="query.content"
           radius="8"
           placeholder="请输入关键字"
           cancelButton="none"
@@ -31,7 +32,6 @@ import { ref, reactive } from 'vue'
 import { onPullDownRefresh } from '@dcloudio/uni-app';
 
 
-let searchContent = ''
 const swiperAdList = ref(swiperAdListTest)
 const filterList = ref([
   { label: '行业' },
@@ -44,10 +44,10 @@ const filterList = ref([
 // 
 const positionListData = ref([])
 const noMore = ref(false)
-const query = reactive({ pageSize: 10, pageNo: 1 })
+const query = reactive({ pageSize: 10, pageNo: 1, content: '' })
 //
 const getData = async () => {
-  query.content = searchContent
+  console.log('getData->query', query)
   const res = await getJobAdvertisedSearch(query)
   const list = res?.data?.list || []
   // const list = positionList
@@ -63,12 +63,11 @@ const getData = async () => {
 }
 getData()
 
-const onSearch = (name) => {
+const onSearch = () => {
   query.pageNo = 1
   noMore.value = false
-  searchContent = name
   positionListData.value = []
-  getData(name)
+  getData()
 }
 
 const loadingMore = () => { // 加载更多
@@ -77,14 +76,14 @@ const loadingMore = () => { // 加载更多
 }
 
 const refresh = () => { // 下拉刷新
-  onSearch(searchContent)
+  onSearch(searchContent.value)
 }
 
 
 //下拉刷新
 onPullDownRefresh(() => { // 下拉刷新
   // debugger
-  onSearch(searchContent)
+  onSearch(searchContent.value)
 })
 
 </script>