【发布时间】:2020-10-06 00:02:41
【问题描述】:
我正在尝试使用带有一些承诺函数的anime.js 为一些元素设置动画,问题是一旦前一个函数成功,第二个函数将不会运行。
<script>
import Splash from '../components/Splash.vue';
import Intro from '../components/Intro.vue';
export default {
components: {
Splash,
Intro,
},
mounted() {
//This is the line of the error `const animateSplash = async () => {`
const animateSplash = async () => {
const splashAnim = this.$anime({
targets: '.logo',
easing: 'cubicBezier(.5, .05, .1, .3)',
keyframes: [
{ duration: 1000, opacity: 0 },
{ duration: 1000, opacity: 1 },
{ delay: 3000, duration: 500, opacity: 0 },
],
complete(anim) {
document.querySelector('.logo-wrapper').style.display = 'none';
},
}).finished;
await Promise.all(splashAnim);
};
animateSplash().then(() => {
const introAnim = this.$anime({
targets: '.intro-wrapper',
easing: 'cubicBezier(.5, .05, .1, .3)',
keyframes: [
{ duration: 1000, opacity: 0 },
{ duration: 1000, opacity: 1 },
],
begin(anim) {
document.querySelector('.intro-wrapper').style.display = 'flex';
},
}).finished;
});
},
};
</script>
我收到一个错误
Home.vue?76f2:17 Uncaught (in promise) TypeError: undefined is not a function 再次指向 const animateSplash = async () => {。但它运行的第一个动画是splashAnim。
【问题讨论】:
-
从你的代码中不清楚
this.$anime是什么,我在你的对象中看不到这样的键,所以它是undefined -
@DmitryReutov 它工作正常,它是一个附加到每个 vue 实例的anime.js 原型
-
这里有 90% 的问题不值得留下。别担心
标签: javascript node.js vue.js promise electron