【发布时间】:2019-10-17 11:31:26
【问题描述】:
我有两种方法:
method_1 和 aysnc method_2;
我想在aysnc method_2 中调用method_1(在检索到一些数据之后);
(aysnc method_2 捕获数据并将其传递给method_1 并执行它。)
我在aysnc method_2 中使用this.method_1 来调用它,但没有任何反应。
method_1 (data) {
console.log( 'I need it here', data );
} ,
triggerByUser () {
this.method_1( 'just a test' );
async function method_2 () {
let code = await fileRetriever( 'songs' );
console.log( 'this code retrieved: ' , code );
this.method_1( code );
console.log( 'the code has been sent!' );
} ;
method_2 ( ) ;
},
结果:
JS: 'I need it here' 'just a test'
JS: 'response From fileRetriever:' 58
JS: 'this code retrieved: ' 58
(项目是在 NativeScript + Vue 上编写的)
【问题讨论】:
-
"我想调用
method_1在完成后async method_2" next "但是当我使用this.method_1 在aysnc method_2内部,什么也没有发生。”。 1.添加实际代码。 2. 之后 OR 里面 ? 3. 如果你能提供一个 codepen 或类似的东西就更好了。 -
你可以看到它卡在这条线上
this.method_1( data.length ); -
@Max 我希望现在已经清楚了。 :)
标签: vuejs2 nativescript nativescript-vue