【发布时间】:2019-01-17 16:47:55
【问题描述】:
我正在使用setTimeout 函数来更新现有的{{title}} 文本。我了解添加淡入淡出过渡的常规方法是将其包裹在 {{title}} 周围,例如:
<transition name="fade">
{{title}}
</transition>
但是,由于标题正在 cycle 函数中更新,我该如何添加淡入淡出过渡?
created: function created() {
var self = this
setTimeout(function cycle() {
self.title = self.posts[self.currentIndex++].title
self.currentIndex %= self.posts.length
setTimeout(cycle, 3000)
}, 5000)
},
【问题讨论】:
标签: javascript vue.js settimeout transition