多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 1.在pages/search.json中添加 ``` { "usingComponents": { "v-search":"/components/search/search" }, "enablePullDownRefresh":true, //不能在子组件中使用 "backgroundColor":"#333" } ``` ## 2.在pages/search.wxml中添加 ``` <v-search topMore="{{topMore}}"></v-search> ``` ## 3.在components/search/search.js中添加 ``` properties: { topMore:{ type:Number, observer:"onPull" }, bottomMore:{ type:Number, observer:"onBottom" } } ``` ``` methods: { onPull(){ this.setData({ books:[] }) bookModel.getBookSearch(0,this.data.value).then(res=>{ this.setData({ books:res.books }) }) }, onBottom(){ const start = this.data.books.length; let value = this.data.value; bookModel.getBookSearch(start,value).then(res=>{ this.data.books.push(...res.books); this.setData({ books:this.data.books }) }) } } ``` ``` onConfirm(event) { let value = event.detail.value; bookModel.getBookSearch(0, value).then(res => { if (res.total) { keyword.addHistory(value); let words = keyword.getHistory(); this.setData({ words, books:res.books, isSearch:true, value }) } }) }, ```