simpilfy back-top.vue
This commit is contained in:
parent
2218620b53
commit
abedec0813
4 changed files with 454 additions and 202 deletions
616
dist/iview.js
vendored
616
dist/iview.js
vendored
File diff suppressed because it is too large
Load diff
10
dist/iview.min.js
vendored
10
dist/iview.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -10,19 +10,6 @@
|
|||
<script>
|
||||
const prefixCls = 'ivu-back-top';
|
||||
|
||||
function getScroll(target, top) {
|
||||
const prop = top ? 'pageYOffset' : 'pageXOffset';
|
||||
const method = top ? 'scrollTop' : 'scrollLeft';
|
||||
|
||||
let ret = target[prop];
|
||||
|
||||
if (typeof ret !== 'number') {
|
||||
ret = window.document.documentElement[method];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
export default {
|
||||
props: {
|
||||
height: {
|
||||
|
@ -72,14 +59,7 @@
|
|||
},
|
||||
methods: {
|
||||
handleScroll () {
|
||||
const backTop = this.backTop;
|
||||
const scrollTop = getScroll(window, true);
|
||||
|
||||
if (this.height <= scrollTop && !backTop) {
|
||||
this.backTop = true;
|
||||
} else if (this.height > scrollTop && backTop) {
|
||||
this.backTop = false;
|
||||
}
|
||||
this.backTop = window.pageYOffset >= this.height;
|
||||
},
|
||||
back () {
|
||||
window.scrollTo(0, 0);
|
||||
|
|
|
@ -50,9 +50,9 @@
|
|||
<div @click="spinShow = !spinShow">消失</div>
|
||||
<br><br>
|
||||
|
||||
<Button @click="nextStep">下一步</Button>
|
||||
<Button @click="step_status = 'error'">步骤3切换为错误</Button>
|
||||
<Button @click="step_process = 'error'">切换steps状态为error</Button>
|
||||
<i-button @click="nextStep">下一步</i-button>
|
||||
<i-button @click="step_status = 'error'">步骤3切换为错误</i-button>
|
||||
<i-button @click="step_process = 'error'">切换steps状态为error</i-button>
|
||||
<Breadcrumb separator="<b>=></b>">
|
||||
<Breadcrumb-item href="/index">首页</Breadcrumb-item>
|
||||
<Breadcrumb-item href="/my">我的</Breadcrumb-item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue