我的代码如下:
<script>
Vue.config.productionTip = false
new Vue({
el: '#root',
data: {
opacity: 1,
name:'你好'
},
//Vue完成模板的解析并把初始的真实DOM元素放入页面后(挂载完毕)调用mounted
mounted() {
console.log('nhao')
setInterval(() => {
this.opacity -= 0.01
if (this.opacity <= 0) this.opacity = 1
}, 16)
},
})
</script>
参考
https://blog.csdn.net/weixin_46188510/article/details/124317264