我真的只是试图让一个简单的Polymer 3应用程序与lit-element工作 . 从VS Code,我运行聚合物服务,当我导航到localhost:8081到我的index.html时,我得到了F12工具中的错误:
Uncaught TypeError:无法解析模块说明符“@ polymer / polymer / lib / mixins / properties-mixin.js” . 相对引用必须以“/”,“./”或“../”开头 .
这非常令人沮丧,我一直试图解决这个问题很长一段时间 .
在HTML中,我只是按预期包含文件:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Polymer 3</title>
<script type="module" src="./node_modules/@polymer/lit-element/lit-element.js"></script>
<script type="module" src="./MyApp.js"></script>
</head>
<body>
<my-app score='5'></my-app>
</body>
</html>
在我的自定义元素的JavaScript文件中,我正在执行以下操作:
import {LitElement, html} from './node_modules/@polymer/lit-element/lit-element.js';
class MyApp extends LitElement {
constructor() {
super();
}//end ctor
static get properties() {
return {
score: Number
}
}//end properties
//no get template needed. Use _render instead
_render({score}) {
return html`The score is ${score}`; //equivalent {{score}} or [[score]]
}//end _render window.customElements.define(MyApp.is, MyApp);
static get is() {
return 'my-app';
}//end is
}//end class
window.customElements.define(MyApp.is(), MyApp);
任何帮助将不胜感激 . 我是一些Web组件技术的新手 . 我已经使用了HTML5,CSS3,JavaScript,jQuery等很长一段时间了,但是对Web组件和Polymer 3的这种新推动就像一个非常不同的动物,我在 grab 工作流的某些方面时遇到了麻烦 .