小程序调用插件导出的async接口无返回
发布于 6 年前 作者 xiulan89 6690 次浏览 来自 问答

插件导出接口:

module.exports = {

testAsync: async ()=> { 

	console.log('Calling testAsync.');

	return 0;

}

};

另起一个小程序(不是与插件同目录的小程序):并在onShow时调用 testAsync

async onShow() {

console.log('Before calling testAsync');

const res = await plugin.testAsync();

console.log('After calling testAsync', res);

}

在开发者工具(1.03.2006090)中能正常打印 After calling testAsync,在与插件同目录的小程序中也能正常打印After calling testAsync,但在真机预览另一个小程序时只打印了Before calling testAsync 和 Calling testAsync,说明插件导出接口有被调用,但无返回。手机锁屏再解锁(即第二次调用onShow)时才有返回。真机调试时均能正常打印。

1 回复

你下面都知道 async await 配套 为什么上面不给console配套 ?

回到顶部