Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄瑜
VueElementTemplate
Commits
bf087566
Commit
bf087566
authored
7 years ago
by
dongsuo
Committed by
花裤衩
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'新增功能:返回顶部'
parent
ba2e4860
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
238 additions
and
1 deletion
+238
-1
index.vue
src/components/BackToTop/index.vue
+92
-0
index.js
src/router/index.js
+3
-1
backToTop.vue
src/views/components/backToTop.vue
+143
-0
No files found.
src/components/BackToTop/index.vue
0 → 100644
View file @
bf087566
<
template
>
<transition
name=
"fade"
>
<div
class=
"back-to-top"
@
click=
"backToTop"
v-show=
"visible"
>
<el-tooltip
class=
"item"
effect=
"dark"
content=
"返回顶部"
placement=
"top"
>
<i
class=
"el-icon-arrow-up"
></i>
</el-tooltip>
</div>
</transition>
</
template
>
<
script
>
export
default
{
name
:
'BackToTop'
,
props
:
{
visibilityHeight
:
{
type
:
Number
,
default
:
400
},
backPosition
:
{
type
:
Number
,
default
:
0
}
},
data
()
{
return
{
visible
:
false
}
},
mounted
()
{
window
.
addEventListener
(
'scroll'
,
this
.
handleScroll
)
},
beforeDestroy
()
{
window
.
removeEventListener
(
'scroll'
,
this
.
handleScroll
)
},
methods
:
{
handleScroll
()
{
this
.
visible
=
window
.
pageYOffset
>
this
.
visibilityHeight
;
},
backToTop
()
{
const
start
=
window
.
pageYOffset
;
let
i
=
0
;
const
t
=
setInterval
(()
=>
{
const
next
=
Math
.
floor
(
this
.
easeInOutQuad
(
10
*
i
,
start
,
-
start
,
500
));
if
(
next
<=
this
.
backPosition
)
{
window
.
scrollTo
(
0
,
this
.
backPosition
);
clearInterval
(
t
)
}
else
{
window
.
scrollTo
(
0
,
next
);
}
i
++
;
},
16.7
)
},
easeInOutQuad
(
t
,
b
,
c
,
d
)
{
if
((
t
/=
d
/
2
)
<
1
)
return
c
/
2
*
t
*
t
+
b
;
return
-
c
/
2
*
(
--
t
*
(
t
-
2
)
-
1
)
+
b
;
}
}
}
</
script
>
<
style
scoped
>
.back-to-top
{
position
:
fixed
;
right
:
50px
;
bottom
:
50px
;
display
:
inline-block
;
height
:
40px
;
width
:
40px
;
box-shadow
:
1px
1px
1px
#58B7FF
;
text-align
:
center
;
cursor
:
pointer
;
background
:
#58B7FF
;
color
:
#fff
;
}
.fade-enter-active
,
.fade-leave-active
{
transition
:
opacity
1s
}
.fade-enter
,
.fade-leave-to
{
opacity
:
0
}
.back-to-top
i
{
display
:
inline-block
;
width
:
100%
;
height
:
100%
;
line-height
:
40px
;
}
</
style
>
This diff is collapsed.
Click to expand it.
src/router/index.js
View file @
bf087566
...
...
@@ -28,6 +28,7 @@ const Sticky = _import('components/sticky');
const
SplitPane
=
_import
(
'components/splitpane'
);
const
CountTo
=
_import
(
'components/countTo'
);
const
Mixin
=
_import
(
'components/mixin'
);
const
BackToTop
=
_import
(
'components/backToTop'
)
/* charts */
const
chartIndex
=
_import
(
'charts/index'
);
...
...
@@ -129,7 +130,8 @@ export const asyncRouterMap = [
{
path
:
'dropzone'
,
component
:
Dropzone
,
name
:
'Dropzone'
},
{
path
:
'sticky'
,
component
:
Sticky
,
name
:
'Sticky'
},
{
path
:
'countto'
,
component
:
CountTo
,
name
:
'CountTo'
},
{
path
:
'mixin'
,
component
:
Mixin
,
name
:
'小组件'
}
{
path
:
'mixin'
,
component
:
Mixin
,
name
:
'小组件'
},
{
path
:
'backtotop'
,
component
:
BackToTop
,
name
:
'返回顶部'
}
]
},
{
...
...
This diff is collapsed.
Click to expand it.
src/views/components/backToTop.vue
0 → 100644
View file @
bf087566
<
template
>
<div
class=
"components-container"
>
<code>
页面滚动到指定位置会在右下角出现返回顶部按钮
</code>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
<back-to-top
id=
"back-to-top-t"
:visibilityHeight=
"300"
:backPosition=
"50"
></back-to-top>
</div>
</
template
>
<
script
>
import
BackToTop
from
'components/BackToTop'
;
export
default
{
components
:
{
BackToTop
}
}
</
script
>
<
style
scoped
>
#back-to-top-t
{
right
:
100px
;
bottom
:
100px
;
}
</
style
>
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment