我想在我的聚合物元素中使用trumbowyg.js,它包括jquery.js和trumbowyg.js。它在Firefox中运行良好但在chrome中不行。
它给出错误,可能是因为影子dom在chrome中查找/分离。这个错误发生在trumbowyg.js使用"这个"的地方。
这里出了什么问题?我该怎么办?
我正在使用Polymer 2.0
错误:
未捕获的TypeError:无法读取属性' toLowerCase'未定义的 at trumbowyg.js:1544
my-notes.html
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../bower_components/trumbowyg/trumbowyg.html">
<dom-module id="my-notes">
<template>
<link rel="stylesheet" href="../bower_components/trumbowyg/dist/ui/trumbowyg.min.css">
<firebase-auth user="{{user}}" signed-in="{{signedIn}}"></firebase-auth>
<div class="card">
<div id="trumbowygd">hello</div>
</div>
</template>
<script>
class MyNotes extends Polymer.Element {
static get is() { return 'my-notes'; }
static get properties() {
return {
user: {
type: Object,
observer: '_shownotearea'
},
};
}
_shownotearea(){
var myFineElement = this.$.trumbowygd;
myFineElement.innerHTML="hello nice meeting you";
$(myFineElement).trumbowyg({});
}
</script>
</dom-module>
trumbowyg.html
<script src="../jquery/dist/jquery.min.js"></script>
<script src="dist/trumbowyg.js"></script>
答案 0 :(得分:0)
简短的回答是这个插件可能不会使用原生的Shadow DOM。
可能trumbowyg正在尝试查询文档以查找某个元素。 Shadow DOM创建了标记封装,因此您无法使用$()
或document.querySelector
来查找阴影根中的内容。一般来说,我建议不要在Shadow DOM中使用jQuery插件。