我怎样才能得到Web组件与打字稿编译IE11 / EDGE /镀铬/火狐?

问题描述 投票:2回答:1

已经成立了一个Web项目使用打字稿/的WebPack我不能让谷歌浏览器运行的结果:

enter image description here

错误写着:“遗漏的类型错误:无法构造‘HTML元素’:请使用‘新’运营商,这个DOM对象的构造不能作为函数调用”

我了解到,a shim is required为transpiling到ES5,但我仍然不能得到这个工作。这可能是因为我不想一个元素添加到HTML,而是我想</根> import "../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle";.ts文件。

我怎样才能得到这个无需添加<SCRIPT>元素,以我的HTML文件?

我把我的tsconfig.jsonwebpack.config.js文件从this tutorial

javascript typescript google-chrome web-component webpack-4
1个回答
3
投票

这里的解决方案:

npm install @webcomponents/webcomponentsjs --save-dev
import "@webcomponents/webcomponentsjs/webcomponents-bundle";
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js';

...

据我所看到的,这个平稳运行在Chrome,火狐,Edge和IE11。

© www.soinside.com 2019 - 2024. All rights reserved.