有两个 Web 组件托管在各自的服务器中。我可以单独查看 Web 组件。
服务器A:
VIEW: abc.com/a/index.html
CONFIGURATION
abc.com/a/a.js
abc.com/a/main.css
<a-webcomponent>
服务器B:
VIEW: abc.com/b/index.html
CONFIGURATION
abc.com/b/b.js
abc.com/b/main.css
<b-webcomponent>
现在我有一个新的 React 项目,我试图在其中显示这两个 Web 组件。所以在我的
index.html
中,我配置了 a-webcomponent
和 b-webcomponent
以在一个项目中查看它们。
<!DOCTYPE html>
<html lang="en">
<head>
<script src="abc.com/a/a.js"></script>
<link href="abc.com/a/main.css" rel="stylesheet"/>
<script src="abc.com/b/b.js"></script>
<link href="abc.com/b/main.css" rel="stylesheet"/>
</head>
<body>
<div id="root"></div>
</body>
</html>
路线
<Route path="/a-webcomponent" Component={AWebComponent} />
<Route path="/b-webcomponent" Component={BWebComponent} />
Web组件
return <a-webcomponent />
BWebComponent
return <b-webcomponent />
问题
在切换路由时,出现以下错误。
未捕获的类型错误:属性“__reactFiber$wqjvbwadizh”不可配置且无法删除
诺诺诺,
A.html和B.html已经托管了,不能像刚才那样简单的组合在一起,有两种方式:
1) 重构你的网站,将 A.html 和 B.html 复制到 New.html,删除旧的 A 和 B,并托管 New。然后访问 New.html。
2)使用iframe,但是这样只会让人们访问A和B,你会失去有机和整体的发展你的工作。
答案是降级 react-dom 版本。
使用 [email protected] 有效。