Answer the question
In order to leave comments, you need to log in
How to write fullpage code in vue.js adding css classes?
fullpage plugin for vue, there is the same one for jquery and I transfer part of the self-written code to vue.
jquery
...
onLeave: function(index, nextIndex, direction){
if(direction == "up"){
$(".section").removeClass("down next prev")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").addClass("up")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").next().addClass("next up")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").prev().addClass("prev up")
}else{
$(".section").removeClass("up next prev")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").addClass("down animate-show")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").next().addClass("next down")
$(".main-deerpfarm .section:nth-child("+nextIndex+")").prev().addClass("prev down")
}
...
VUE.js
...
onLeave: function(index, nextIndex, direction){
if(direction == 'up') {
// ???????
} else {
// ???????
}
Answer the question
In order to leave comments, you need to log in
data(){
return {
classDir: '',
}
}
onLeave(i, ni, dir){
this.classDir = dir;
}
<div :class="{up: classDir}">
Don't try to manipulate the DOM directly, but change the component's data!
Forget about this jQuery-style at last!!!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question