Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -25,6 +25,7 @@ export struct SearchComponent { | @@ -25,6 +25,7 @@ export struct SearchComponent { | ||
| 25 | @State isClickedHintSearch: boolean = false | 25 | @State isClickedHintSearch: boolean = false |
| 26 | private swiperController: SwiperController = new SwiperController() | 26 | private swiperController: SwiperController = new SwiperController() |
| 27 | @State searchText: string = '' | 27 | @State searchText: string = '' |
| 28 | + @State searchTextNum: number = 0 | ||
| 28 | controller: SearchController = new SearchController() | 29 | controller: SearchController = new SearchController() |
| 29 | @State searchHistoryData: SearchHistoryItem[] = [] | 30 | @State searchHistoryData: SearchHistoryItem[] = [] |
| 30 | @State relatedSearchContentsData: SearchRelatedItem[] = [] | 31 | @State relatedSearchContentsData: SearchRelatedItem[] = [] |
| @@ -281,7 +282,7 @@ export struct SearchComponent { | @@ -281,7 +282,7 @@ export struct SearchComponent { | ||
| 281 | //左 | 282 | //左 |
| 282 | Stack({ alignContent: Alignment.Start }) { | 283 | Stack({ alignContent: Alignment.Start }) { |
| 283 | if (this.searchTextData != null && this.searchTextData.length > 0 && !this.hasInputContent && | 284 | if (this.searchTextData != null && this.searchTextData.length > 0 && !this.hasInputContent && |
| 284 | - StringUtils.isEmpty(this.searchText)) { | 285 | + this.searchTextNum === 0) { |
| 285 | Swiper(this.swiperController) { | 286 | Swiper(this.swiperController) { |
| 286 | ForEach(this.searchTextData, (item: string, index: number) => { | 287 | ForEach(this.searchTextData, (item: string, index: number) => { |
| 287 | Text(item) | 288 | Text(item) |
| @@ -320,6 +321,10 @@ export struct SearchComponent { | @@ -320,6 +321,10 @@ export struct SearchComponent { | ||
| 320 | style: CancelButtonStyle.INVISIBLE | 321 | style: CancelButtonStyle.INVISIBLE |
| 321 | }) | 322 | }) |
| 322 | .caretStyle({ color: Color.Pink }) | 323 | .caretStyle({ color: Color.Pink }) |
| 324 | + ///监听搜索框变化 | ||
| 325 | + .onTextSelectionChange((selectionStart: number) =>{ | ||
| 326 | + this.searchTextNum = selectionStart; | ||
| 327 | + }) | ||
| 323 | .onSubmit((value: string) => { | 328 | .onSubmit((value: string) => { |
| 324 | if (StringUtils.isNotEmpty(this.searchText)) { | 329 | if (StringUtils.isNotEmpty(this.searchText)) { |
| 325 | SearcherAboutDataModel.putSearchHistoryData(this.searchText) | 330 | SearcherAboutDataModel.putSearchHistoryData(this.searchText) |
-
Please register or login to post a comment