我可以在JSFiddle上使用Polymer吗?

Kay*_*ues 7 javascript jsfiddle jsbin polymer polymer-1.0

我想在像JSFiddle或JavaScript Bin这样的沙箱中创建Polymer元素的快速原型,但是我无法让它工作!

Kay*_*ues 10

是的,你可以,多亏了多元文章.

这是一个可以分叉的样板示例:https://jsfiddle.net/kaycebasques/2q3fqehz/

HTML:

<base href="https://polygit.org/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="polymer/polymer.html" rel="import">

<dom-module id="x-example">
  <template>
    <style>
      :host {
        display: block;
      }
    </style>
    <h1>polyfiddle</h1>
  </template>
</dom-module>

<x-example></x-example>
Run Code Online (Sandbox Code Playgroud)

JS:

// only need this when in the main document and on non-Chrome
addEventListener('WebComponentsReady', function() {
  Polymer({
    is: 'x-example'
  });
});
Run Code Online (Sandbox Code Playgroud)