mirror of
https://gitee.com/wangkang/udf.git
synced 2026-11-17 01:55:15 +00:00
下拉刷新
This commit is contained in:
+3
-4
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ const glob = {
|
||||
eventNames: {
|
||||
//全局搜索事件名称
|
||||
globSearchEventName: 'globSearch',
|
||||
//全局刷新事件名称
|
||||
globRefreshEventName: 'globRefresh',
|
||||
},
|
||||
//初始化
|
||||
inti() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user