我已经成功创建了在角度项目中命名的角度自定义元素,并且我想在另一个角度项目中使用此自定义元素 我尝试使用以下方式:
profile.js
文件,并在index.html
中的另一个项目的标签中使用了但是由于GET http://localhost:4200/profile.js net :: ERR_ABORTED 404(未找到)而出现错误
Index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.1.3/custom-elements-es5-adapter.js"></script>
<script src="https://unpkg.com/zone.js"></script>
<script type="text/javascript" src="/profile.js"></script>
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-profile></app-profile>
<app-root></app-root>
</body>
</html>
答案 0 :(得分:0)
我的猜测是,您将profile.js
文件与Angular项目的源文件放在一起。尝试将其移至dist
文件夹(放置编译文件的文件夹,并在运行ng serve
时从该文件夹提供编译的应用程序)