使用方法一:
npm install gsap
import gsap from "gsap"
;<template>
<div>{{ animatedNumber }}</div>
</template>
<script>
import gsap from "gsap";
export default {
data () {
return {
number: 0,
tweenedNumber: 0
}
},
computed: {
animatedNumber: function() {
return this.tweenedNumber.toFixed(0);
}
},
created(){
gsap.to(this.$data, { duration: 0.5, tweenedNumber: 666666 });
},
}
</script>
使用方法二:
npm install gsap
import gsap from "gsap"
Vue.prototype.gsap = gsap
<template>
<div>{{ animatedNumber }}</div>
</template>
<script>
export default {
data () {
return {
number: 0,
tweenedNumber: 0
}
},
computed: {
animatedNumber: function() {
return this.tweenedNumber.toFixed(0);
}
},
created(){
this.gsap.to(this.$data, { duration: 0.5, tweenedNumber: 80 });
},
}
</script>