L
L
LS Timer2018-11-01 15:57:42
JavaScript
LS Timer, 2018-11-01 15:57:42

Why is async/await not working in Vue?

<button @click="test">Test</button>

test: async function () {
    await setTimeout(function () {
        console.log("pause");
    }, 2000);
    console.log("end");
},

Why the first in the console there is "end" then "pause".
In Vue components, everything works without problems
. I use Vuex

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2018-11-01
@light___soul

And it shouldn't work. Await expects a promise, but setTimeout doesn't return it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question