webpack error

 chromium: [INFO:CONSOLE(10)] "Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode", 
source:http://beta.webapp.skysrt.com/yuanbo/test/41834123452234532345423455234523/index.html?theme=dark (10)
Ans: html里匿名函数里使用了let,但没有声明为'use strict'


 "Unhandled promise rejection", 
 source: webpack:///./node_modules/_core-js@3.6.4@core-js/internals/host-report-errors.js? (6)
 Ans:
 原因是
asyn init() {
	await ccApi.tv.init() //原因是这里promise里出错了,不是reject的错误,是在getdeviceinfo前调用getvideosource,顺序错误导致的变量undefined错误,抛出异常
} 
解决方法:
async init() {
	try {
		await ccApi.tv.init()	
	} catch (e) { //在这里捕获异常
		console.error(e)
	}
}

Async/Await 中
在 Async/Await 中,unhandled promise rejection 是这样触发:


// Promise 未能阻止异常抛出
;(async () => {
  await (new Promise((resolve, reject) => {
    reject('timeout');
  }));
})();
// async 没有妥善处理异常,需要改为如下:
;(async () => {
  try {
    await (new Promise((resolve, reject) => {
      reject('timeout');
    }));
  } catch(e) {
    throw new Error(e);
  }
})();

 参考 
 https://www.jianshu.com/p/232a8cc149d7
 https://es6.ruanyifeng.com/#docs/async#%E4%B8%8E%E5%85%B6%E4%BB%96%E5%BC%82%E6%AD%A5%E5%A4%84%E7%90%86%E6%96%B9%E6%B3%95%E7%9A%84%E6%AF%94%E8%BE%83
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值