Javascript aurelia、es6和classname案例
我正在研究Aurelia中的定制组件,遇到了我不理解的奇怪行为。考虑这一点: 组成部分: xxxaaa.htmlJavascript aurelia、es6和classname案例,javascript,ecmascript-6,babeljs,aurelia,Javascript,Ecmascript 6,Babeljs,Aurelia,我正在研究Aurelia中的定制组件,遇到了我不理解的奇怪行为。考虑这一点: 组成部分: xxxaaa.html <template> <div>xxxxxx</div> </template> app.html: <template> <import from='./xxxaaa'></import> <div> <xxxaaa/> &l
<template>
<div>xxxxxx</div>
</template>
app.html:
<template>
<import from='./xxxaaa'></import>
<div>
<xxxaaa/>
</div>
</template>
app.html:
<template>
<import from='./xxxAaa'></import>
<div>
<xxxAaa/>
</div>
</template>
控制台日志错误:
Potentially unhandled rejection [1] TypeError: Cannot call a class as a function
at execute._classCallCheck (http://localhost:9090/dist/xxxaaa.js:9:108)
at xxxaaa (http://localhost:9090/dist/xxxaaa.js:12:9)
at Container.invoke (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:362:27)
at Array.<anonymous> (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:142:52)
at Container.get [as superGet] (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:238:32)
at Container.elementContainerGet [as get] (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:27:17)
at CustomElement.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/custom-element.js:136:80)
at applyInstructions (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:79:33)
at ViewFactory.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:172:17)
at CustomElement.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/custom-element.js:141:58)
可能未处理的拒绝[1]类型错误:无法将类作为函数调用
在执行时。\u classCallCheck(http://localhost:9090/dist/xxxaaa.js:9:108)
在xxxaaa(http://localhost:9090/dist/xxxaaa.js:12:9)
在Container.invoke(http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:362:27)
在Array.,)但我是否正确地理解了这又是一个来自aurelia的错误报告糟糕的情况?aurelia从未看到camelcased标记,因为DOM降低了元素和属性名称的大小写
查看答案了解更多信息。这里有一段摘录:
不过,还有一件事需要注意:在所有浏览器中,当浏览器加载HTML文档并对其进行解析时,它会将其转换为DOM(文档对象模型)。如果随后使用浏览器的内置开发人员工具检查站点,则在查看DOM时,DOM中的所有元素都将显示为小写,而不管它们在实际源代码中是如何编写的
另一种方法:
如果您将类命名为XxxAaaCustomElement
,您将能够在标记中使用
。感谢您指向CustomElement,这确实让它变得更简单。但我仍然想确保我完全理解这些案例。我更新了问题,让它们更明确,你能看一下吗?
<template>
<import from='./xxxAaa'></import>
<div>
<xxxAaa/>
</div>
</template>
export class xxxaaa {}
Potentially unhandled rejection [1] TypeError: Cannot call a class as a function
at execute._classCallCheck (http://localhost:9090/dist/xxxaaa.js:9:108)
at xxxaaa (http://localhost:9090/dist/xxxaaa.js:12:9)
at Container.invoke (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:362:27)
at Array.<anonymous> (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:142:52)
at Container.get [as superGet] (http://localhost:9090/jspm_packages/github/aurelia/dependency-injection@0.4.5/container.js:238:32)
at Container.elementContainerGet [as get] (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:27:17)
at CustomElement.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/custom-element.js:136:80)
at applyInstructions (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:79:33)
at ViewFactory.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/view-factory.js:172:17)
at CustomElement.create (http://localhost:9090/jspm_packages/github/aurelia/templating@0.8.14/custom-element.js:141:58)