這篇文章主要介紹使用vux實(shí)現(xiàn)上拉刷新功能遇到的問題 有哪些,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)公司是網(wǎng)站建設(shè)專家,致力于互聯(lián)網(wǎng)品牌建設(shè)與網(wǎng)絡(luò)營(yíng)銷,專業(yè)領(lǐng)域包括成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、電商網(wǎng)站制作開發(fā)、小程序定制開發(fā)、微信營(yíng)銷、系統(tǒng)平臺(tái)開發(fā),與其他網(wǎng)站設(shè)計(jì)及系統(tǒng)開發(fā)公司不同,我們的整合解決方案結(jié)合了恒基網(wǎng)絡(luò)品牌建設(shè)經(jīng)驗(yàn)和互聯(lián)網(wǎng)整合營(yíng)銷的理念,并將策略和執(zhí)行緊密結(jié)合,且不斷評(píng)估并優(yōu)化我們的方案,為客戶提供全方位的互聯(lián)網(wǎng)品牌整合方案!最近公司在研發(fā)app,選擇了基于Vue框架的vux組件庫(kù),現(xiàn)總結(jié)在實(shí)現(xiàn)上拉刷新功能遇到的坑:
1.問題:只刷新一次,解決方法:需要自己手動(dòng)重置狀態(tài)
this.scrollerStatus.pullupStatus = ‘default',
2.問題:不能滾動(dòng),解決方法:因?yàn)閱⒂胟eep-alive緩存,需要設(shè)置
activated () { this.$refs.scroller.reset() }
如果還沒效果,請(qǐng)?jiān)讷@取后臺(tái)數(shù)據(jù)后,執(zhí)行如下代碼
this.$nxtTick(() => { this.$refs.scroller.reset() })
貼出整個(gè)頁(yè)面的代碼。
<template> <div > <x-header slot="header" :left-options="{showBack: false}" >會(huì)議列表 <a slot="right" v-on:click="show = true" > <icon type="search"></icon> </button> </a> </x-header> <!-- 會(huì)議列表 --> <scroller v-model="scrollerStatus" height="-46" lock-x scrollbar-y ref="scroller" :bounce="isbounce" :use-pullup="showUp" :pullup-config="upobj" @on-pullup-loading="selPullUp" > <div class="box2"> <p v-for="list, index in lists"> <router-link :to="{ path: list.id } "> <p > <span class="spanMeetTitle" v-html='(index+1) + " . " + list.name' ></span> <span class="spanMeetStatu" v-html='list.status'></span> </p> <p class="prevSuper"> <form-preview header-label="" header-value="" :bodyItems="list" :footer-buttons="buttons1"></form-preview> </p> </router-link> <hr> </p> </div> </scroller> <!-- 導(dǎo)航 --> <Home></Home> <!-- 搜索 --> <popup v-model="show" @on-hide="log('hide')" @on-show="log('show')" height="93%"> <div class="popup0"> <group> <x-input v-model='meetName' placeholder="請(qǐng)輸入“會(huì)議名稱”搜索"></x-input> <div ><icon type="search"></icon></div> </group> <!-- <group> <checklist :max=1 title="會(huì)議審批狀態(tài)" required :options="commonList" v-model="checkStatus" @on-change="change"></checklist> </group> --> <group title="會(huì)議審批狀態(tài)"> <radio :options="commonList" v-model="checkStatus" @on-change="change"></radio> </group> <group title="會(huì)議類型"> <selector placeholder="請(qǐng)選擇會(huì)議類型" v-model="checkType" :options="meetType"></selector> </group> <group title="召開時(shí)間"> <flexbox> <flexbox-item> <div class="flex-demo" > <datetime title='' placeholder="請(qǐng)選擇" v-model="startTime" format="YYYY-MM-DD HH:mm" @on-change="change" ></datetime> </div> </flexbox-item> 至 <flexbox-item> <div class="flex-demo" > <datetime title='' placeholder="請(qǐng)選擇" v-model="stopTime" format="YYYY-MM-DD HH:mm" @on-change="change" ></datetime> </div> </flexbox-item> </flexbox> </group> <br> <flexbox orient="vertical"> <flexbox-item><div class="flex-demo" v-on:click="toSearch" >確定</div></flexbox-item> <flexbox-item><div class="flex-demo" v-on:click="show = false" >取消</div></flexbox-item> </flexbox> </div> </popup> <toast v-model="showToast">已加載全部數(shù)據(jù)</toast> <loading v-model="isShowLoading" :text="textLoading"></loading> <alert v-model="isShowAlert" :title="AlertCongratulations" > {{ alertMessage }}</alert> </div> </template> <style type="text/css"> .weui-form-preview__value{ font-size: 1.1em !important; color: black; } .spanMeetTitle{ float: left; border-radius: 13px; padding:10px 6px; font-size: 15px; font-weight: bold; margin-left: 3px; color: black; } .spanMeetStatu{ float: right; background-color: green; border-radius: 10px; padding:6px 5px; color: white; font-size: 13px; margin-top: 5px; } .flex-demo{ height: 30px;padding-top: 5px; } .selected{ color: blue !important; background-color: transparent; } .popup0 { padding-bottom:15px; height:200px; } .popup1 { width:100%; height:100%; } .popup2 { padding-bottom:15px; height:400px; } .box1 { height: 100px; position: relative; width: 1490px; } .box1-item { width: 200px; height: 100px; background-color: #ccc; display:inline-block; margin-left: 15px; float: left; text-align: center; line-height: 100px; } .box1-item:first-child { margin-left: 0; } .box2-wrap { height: 300px; overflow: hidden; } </style> <script> import { XHeader, Group, FormPreview, Tabbar, TabbarItem, Scroller, Icon, Popup, XSwitch, Toast, XInput, Checklist, Datetime, Flexbox, FlexboxItem, Selector, Loading, Alert, Radio } from 'vux' import Home from './Home' export default { components: { XHeader, Home, Group, FormPreview, Tabbar, TabbarItem, Scroller, Icon, Popup, XSwitch, Toast, XInput, Checklist, Datetime, Flexbox, FlexboxItem, Selector, Loading, Alert, Radio }, data () { return { type: '1', PageIndex: 0, show: false, showToast: false, showloading: false, showUp: true, isbounce: false, isShowAlert: false, AlertCongratulations: '條件有誤', textloading: '加載中', alertMessage: '‘召開時(shí)間' 不能大于 ‘結(jié)束時(shí)間'', value: '', meetName: '', startTime: '', stopTime: '', meetType: [], commonList: [{key: '20', value: '審批中'}, {key: '50', value: '審批通過(guò)'}, {key: '', value: '全部'}], checkStatus: '', checkType: '', commonList2: [], results: [], lists: [[]], buttons1: [{ style: 'primary', text: '查看更多', link: '/Message' }], upobj: { content: '請(qǐng)上拉刷新數(shù)據(jù)', pullUpHeight: 60, height: 40, autoRefresh: false, downContent: '請(qǐng)上拉刷新數(shù)據(jù)', upContent: '請(qǐng)上拉刷新數(shù)據(jù)', loadingContent: '加載中...', clsPrefix: 'xs-plugin-pullup-' }, isShowLoading: false, textLoading: '加載中', scrollerStatus: { pullupStatus: 'default' } } }, mounted () { console.log(this.scrollerStatus.pullupStatus) this.getMeetList(true) this.getMeetType() this.$nextTick(() => { this.$refs.scroller.reset() }) }, methods: { log (str) { console.log(str) }, getMeetList (isEmpty) { var APPROVE_STATUS = this.checkStatus var MEETING_TYPE = this.checkType this.isShowLoading = true this.$http.post(global.httpsUrl + '/Meet/GetMeetList', {'HumanId': global.userid, 'KEY': this.meetName, 'APPROVE_STATUS': APPROVE_STATUS, 'MEETING_TYPE': MEETING_TYPE, 'START_DATE': this.startTime, 'STOP_DATE': this.stopTime, 'PageIndex': this.PageIndex, 'PageSize': '2'}).then(response => { // sucess callback console.log('111') var data = response.body.Data if (isEmpty) { this.lists = [] this.show = false } else { if (data && data.length === 0) { this.showToast = true this.isShowLoading = false this.scrollerStatus.pullupStatus = 'disabled' // 禁用下拉 return } } for (var i = 0; i < data.length; i++) { if (data[i].APPROVE_STATUS < 20) { break } var personName = data[i].PERSION1_NAME if (personName && personName.length > 0) { personName = personName.substring(0, personName.indexOf('>')) } var meetlist = [] var obj = { label: '地點(diǎn)', value: data[i].ADDRESS } meetlist.push(obj) obj = { label: '主持人', value: personName } meetlist.push(obj) obj = { label: '召開時(shí)間', value: global.formatDate.methods.toSet(data[i].ACT_START_TIME, 'yyyy-MM-dd HH:mm') } meetlist.push(obj) obj = { label: '會(huì)議類型', value: data[i].MEETING_TYPE_NAME } meetlist.push(obj) meetlist.id = 'FromMeet/' + data[i].MEETING_MINUTES_GUID + '/123' meetlist.name = data[i].MEETING_NAME var vstatus = '審批中' if (data[i].APPROVE_STATUS === 50) { vstatus = '審批通過(guò)' } meetlist.status = vstatus this.lists.push(meetlist) } this.isShowLoading = false if (!isEmpty) { this.scrollerStatus.pullupStatus = 'default' // this.$refs.scroller.reset() console.log(this.scrollerStatus.pullupStatus) this.$nextTick(() => { this.$refs.scroller.reset() }) } }, response => { // error callback this.show = false }) }, showSearch () { this.show = true }, change (val) { console.log('change', val) console.log(this.startTime) }, change2 (val) { console.log('change', val) }, resultClick () { }, getResult () { }, toSearch () { console.log(2222) if (this.startTime && this.stopTime && this.startTime > this.stopTime) { this.isShowAlert = true } else { this.PageIndex = 0 this.getMeetList(true) } }, selPullUp () { console.log('上拉刷新數(shù)據(jù)') this.PageIndex++ this.getMeetList(false) }, getMeetType () { this.$http.post(global.httpsUrl + '/Meet/GetMeetType').then(response => { // sucess callback var data = response.body.Data for (var i = data.length - 1; i >= 0; i--) { var obj = { key: data[i].TYPE_GUID, value: data[i].TYPE_NAME } this.meetType.push(obj) } }, response => { // error callback }) } }, activated () { this.$refs.scroller.reset() } } </script> <style lang="less"> @import '~vux/src/styles/1px.less'; .flex-demo { text-align: center; color: #fff; background-color: #20b907; border-radius: 4px; background-clip: padding-box; } </style>
以上是“使用vux實(shí)現(xiàn)上拉刷新功能遇到的問題 有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
名稱欄目:使用vux實(shí)現(xiàn)上拉刷新功能遇到的問題有哪些-創(chuàng)新互聯(lián)
本文來(lái)源:http://www.rwnh.cn/article10/igodo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、微信公眾號(hào)、響應(yīng)式網(wǎng)站、服務(wù)器托管、搜索引擎優(yōu)化、移動(dòng)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容