下拉刷新

This commit is contained in:
iizmg
2020-05-25 09:53:16 +08:00
parent 601b57b2e6
commit 20b3cbdc9f
4 changed files with 26 additions and 5 deletions
+3 -4
View File
@@ -94,7 +94,6 @@
<div class="mainDiv">
<div v-if="moveState > 0">
<div v-if="moveState === 1" class="text-center">释放即可刷新...</div>
<div v-else-if="moveState === 2" class="text-center">加载中...</div>
</div>
<el-main>
<transition name="el-zoom-in-center">
@@ -249,7 +248,7 @@
let move = e.targetTouches[0].clientY - this.startY;
if (move > 0) {
e.preventDefault();
this.moveDistance = Math.pow(move, 0.8);
this.moveDistance = Math.pow(move, 0.7);
if (this.moveDistance > 50) {
if (this.moveState === 1) return;
this.moveState = 1;
@@ -265,9 +264,9 @@
//下拉刷新逻辑
{
if (this.moveDistance > 50) {
this.moveState = 2;
this.moveDistance = 50;
window.location.reload();
this.$EventBus.$emit(glob.eventNames.globRefreshEventName);
this.moveState = 0;
} else {
this.moveDistance = 0;
}
+2
View File
@@ -8,6 +8,8 @@ const glob = {
eventNames: {
//全局搜索事件名称
globSearchEventName: 'globSearch',
//全局刷新事件名称
globRefreshEventName: 'globRefresh',
},
//初始化
inti() {
+6
View File
@@ -23,11 +23,17 @@
},
activated() {
this.$EventBus.$on(glob.eventNames.globSearchEventName, this.globSearchHandle);
this.$EventBus.$on(glob.eventNames.globRefreshEventName, this.globRefreshHandle);
},
deactivated() {
this.$EventBus.$off(glob.eventNames.globSearchEventName);
this.$EventBus.$off(glob.eventNames.globRefreshEventName);
},
methods: {
//全局刷新
globRefreshHandle() {
window.location.reload();
},
//全局搜索事件处理器
globSearchHandle(searchText) {
console.log(searchText);
+15 -1
View File
@@ -7,8 +7,22 @@
</template>
<script>
import glob from "../assets/js/glob";
export default {
name: "home"
name: "home",
activated() {
this.$EventBus.$on(glob.eventNames.globRefreshEventName, this.globRefreshHandle);
},
deactivated() {
this.$EventBus.$off(glob.eventNames.globRefreshEventName);
},
methods: {
//全局刷新
globRefreshHandle() {
window.location.reload();
}
}
}
</script>