如何将JScrollability插件导入我的VueJS应用程序



我正在尝试使用https://adfero.github.io/jScrollability/插件在我的VueJS应用程序中没有成功。我正在努力导入jquery插件代码。。

我该怎么做?

谢谢!

我抓取了这个演示的内容,并将其封装在Vue:中

new Vue({
el: '#app',
data: () => ({
sections: [
{ title: 'jScrollability Demo' },
{ title: 'Slide From Bottom', class: 'reveal-demo' },
{ title: 'Slide elements in', class: 'slide-in-demo' }
]
}),
mounted() {
$.jScrollability([{
'selector': '.slide-in-demo',
'start': 'parent',
'end': 'parent',
'fn': {
'left': {
'start': 100,
'end': 0,
'unit': '%'
}
}
},
{
'selector': '.reveal-demo',
'start': 'parent',
'end': 'parent',
'fn': {
'top': {
'start': 100,
'end': 0,
'unit': '%'
}
}
}
]);
}
})
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
body {
font-family: 'Roboto', sans-serif;
overflow-x:hidden;
}
.section {
clear: both;
width: 100%;
height: 100vh;
box-sizing: border-box;
position: relative;
}
.section:nth-child(odd) {
color: #220044;
}
.section:nth-child(even) {
background: #220044;
color: white;
}
.section-0 {
text-align: center;
}
.section-0 h1 {
font-size: 7em;
line-height: 1em;
position: absolute;
top: 30%;
left: 0;
right: 0;
text-align: center;
}
.section-0 h1 {
font-size: 4em;
line-height: 1em;
position: absolute;
top: 45%;
left: 0;
right: 0;
text-align: center;
}
.section .slide-in-demo {
position: absolute;
top: 40%;
width: 100%;
left: 0;
text-align: center;
font-size: 4em;
}
.section .reveal-demo {
position: absolute;
top: 0%;
width: 100%;
left: 0;
right: 0;
text-align: center;
font-size: 4em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/AdferoInteractive/jScrollability/jScrollability.min.js"></script>
<div id="app">
<section class="section" :class="[`section-${key}`]" v-for="(section, key) in sections" :key="key">
<h1 :class="section.class" v-text="section.title" />
</section>
</div>

它最初的CSS写得很差(具有非响应的硬编码paddingheight值(,而且它显然是针对桌面屏幕的。运行演示的最简单方法是在这里复制CSS并对其进行调整,但我强烈建议不要重复使用它

我只是想给你一个关于如何协调jQuery.jScrollability和Vue的大致想法。

最新更新