简体   繁体   English

聚合物修复搞砸了Javascript

[英]Polymer fix messing up Javascript

I'm new to Polymer and as far as I've read about it, it isn't compatible with Mozilla and Safari or it has issues. 我是Polymer的新手,据我所知,它与Mozilla和Safari不兼容,或者有问题。 I've read in StackOverflow that adding 我在StackOverflow中读到了

addEventListener('WebComponentsReady', function() {
});

would help the browsers cope up with the code. 可以帮助浏览器处理代码。 Now, I've tried it on my code it works. 现在,我已经在我的代码上对其进行了尝试。 The content is displaying properly in Mozilla, however, it messes up the Javascript that I wrote along with Polymer. 内容在Mozilla中可以正确显示,但是,它弄乱了我与Polymer一起编写的Javascript。 I tried two options, the first one 我尝试了两种选择,第一种

addEventListener('WebComponentsReady', function() {
    Polymer({
      is: "main-header"
    }); });

I did this and there are still error logs on the console while if I wrap the whole script, it wouldn't work as well. 我这样做了,但控制台上仍然有错误日志,但是如果包装整个脚本,它也将无法正常工作。 Example: 例:

 addEventListener('WebComponentsReady', function() {
    Polymer({
      is: "main-header"
    }); 
    // extra code here
 });

I think wrapping addEventListener to the whole code is also causing the problem. 我认为将addEventListener包装到整个代码中也引起了问题。 Any ideas how to fix or are there any other viable options than adding an event listener to the code? 除了将事件侦听器添加到代码中之外,是否有其他解决方法,或者还有其他可行的选择?

Try using Polymer-CLI 尝试使用Polymer-CLI

It comes with some polyfills out of the box. 它带有一些开箱即用的填料。 I'm not sure whitch ones but it does include the one your inquiring about. 我不确定那是什么,但确实包括您要查询的那一个。

https://www.polymer-project.org/1.0/docs/tools/polymer-cli https://www.polymer-project.org/1.0/docs/tools/polymer-cli

It looks like using 看起来像使用

addEventListener('WebComponentsReady', function() {
});

is messing up my Javascript because it has a conflict with 正在弄乱我的Javascript,因为它与

addEventListener('HTMLImportsReady', function() {
});

I had to remove it in order for the script to work properly. 我必须将其删除才能使脚本正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM