Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cli
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
gic-web
gic-cli
Commits
0f7da6e0
Commit
0f7da6e0
authored
Oct 31, 2022
by
caoyanzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 滚动指令
parent
0ebacfe8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletions
+45
-1
main.js
src/main.js
+1
-0
home-view.vue
src/views/module-a/home-view.vue
+21
-1
directives.js
utils/directives.js
+23
-0
No files found.
src/main.js
View file @
0f7da6e0
...
...
@@ -4,6 +4,7 @@ import axios from 'axios';
import
App
from
'./App.vue'
;
import
router
from
'./router'
;
import
store
from
'./store'
;
import
'../utils/directives.js'
;
axios
.
defaults
.
withCredentials
=
true
;
Vue
.
config
.
productionTip
=
false
;
...
...
src/views/module-a/home-view.vue
View file @
0f7da6e0
<
template
>
<div
class=
"home"
>
<div
class=
"home"
v-loadmore:
[
target
]="
onLoadMore
"
>
<img
class=
"logo"
alt=
"Vue logo"
src=
"../../assets/logo.png"
/>
<dm-sub-title
text=
"hello world"
></dm-sub-title>
<div
style=
"width: 300px; height: 100px; overflow-y: auto"
id=
"test"
>
<div
v-for=
"el in 20"
:key=
"el"
style=
"height: 20px; line-height: 20px; border: 1px solid red"
>
{{
formatters
.
formatDate
(
Date
.
now
())
}}
</div>
</div>
</div>
</
template
>
<
script
>
export
default
{
name
:
'HomeView'
,
inject
:
[
'formatters'
],
data
()
{
return
{
target
:
'#test'
,
};
},
methods
:
{
onLoadMore
()
{
console
.
log
(
'hello'
);
},
},
};
</
script
>
...
...
utils/directives.js
0 → 100644
View file @
0f7da6e0
import
Vue
from
'vue'
;
const
directive
=
{
loadmore
:
{
inserted
(
el
,
binding
)
{
let
DOM
=
el
;
if
(
binding
.
arg
)
{
DOM
=
el
.
querySelector
(
binding
.
arg
);
}
DOM
.
addEventListener
(
'scroll'
,
function
()
{
const
CONDITION
=
this
.
scrollHeight
-
this
.
scrollTop
<=
this
.
clientHeight
;
if
(
CONDITION
)
{
binding
.
value
();
}
});
},
},
};
Object
.
keys
(
directive
).
forEach
((
k
)
=>
{
Vue
.
directive
(
k
,
directive
[
k
]);
});
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