I have a component in Nuxt with the following HTML in the template:
<div class="slider" id="slider" ref="slider" :style="'transform: transitionX(-' + sliderPosition + '%)'">
Then I also have a data variable:
export default {
data() {
return {
sliderPosition: 0
}
},
methods: {
moveLeft() {
this.sliderPosition -= 25
console.log(this.sliderPosition)
},
Now, every time I click the button that triggers the method, the console logs out the incremented sliderPosition value. But in the template it always stays 0 and never updates - the transitionX is never changed (shows 0% in Chrome inspector and doesn't change).
Why could this be?
transformfunctiontransitionX- docs. I guess you wantedtranslateXsliderPositionis negative and you have a-in the style expression. So if the value ofsliderPositionis-25the style istranslateX(--25)which is not validSo just to be clear, this is not a problem of Vue not updating the DOM but instead problem of browser not accepting invalid style...