首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >聚合物2.x代码工作在jsbin,但不工作在密码,柱塞或摇铃

聚合物2.x代码工作在jsbin,但不工作在密码,柱塞或摇铃
EN

Stack Overflow用户
提问于 2017-09-04 07:57:32
回答 2查看 238关注 0票数 1

下面的代码在这个jsbin中正常工作,但在这个密码这个柱塞这弹琴中都不工作。

为什么不行?我怎样才能让它在不工作的三个地方工作呢?

http://jsbin.com/yudavucola/1/edit?html,console,output

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>

  <base href="http://polygit.org/polymer+:master/components/">
  <script src="webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="polymer/polymer-element.html">
  <link rel="import" href="paper-dialog/paper-dialog.html">

  <!-- Ensure Web Animations polyfill is loaded since neon-animation 2.0 doesn't import it -->
  <link rel="import" href="neon-animation/web-animations.html">
  <link rel="import" href="neon-animation/animations/scale-up-animation.html">
  <link rel="import" href="neon-animation/animations/fade-out-animation.html">

</head>
<body>
  <dom-module id="my-el">
    <template>
      <button on-click="open">Open Dialog</button>
      <paper-dialog
        id="dialog"
        entry-animation="scale-up-animation"
        exit-animation="fade-out-animation"
        modal
       >
        <h2>Header</h2>
        <div>Dialog body</div>
      </paper-dialog>
    </template>
    <script>
      class MyEl extends Polymer.Element {
        static get is() { return 'my-el' }

    constructor() {
      super();
        }

        open() {
          console.log('opening...');
          this.$.dialog.open();
          console.log('opened!');
        }

      }

      customElements.define(MyEl.is, MyEl);
    </script>
  </dom-module>

  <my-el></my-el>
</body>
</html>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-09-05 02:03:00

由于jsbin以外的其他站点都在使用HTTP的安全版本(即HTTPS ),因此从源http://polygit.org/polymer+:master/components/获取内容的请求将被阻止。所以,使用安全连接,它将在所有其他站点工作。

您可以检查控制台以获得更多信息。

票数 1
EN

Stack Overflow用户

发布于 2017-09-05 07:55:51

<base>标记的href属性从http://polygit.org/...更改为//polygit.org/...。这使导入在httphttps环境中都能正常工作。

以下是所有存储库中的工作示例:JsBin科德芬柱塞JsFiddle

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>

  <base href="//polygit.org/polymer+:master/components/">
  <script src="webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="polymer/polymer-element.html">
  <link rel="import" href="paper-dialog/paper-dialog.html">

  <!-- Ensure Web Animations polyfill is loaded since neon-animation 2.0 doesn't import it -->
  <link rel="import" href="neon-animation/web-animations.html">
  <link rel="import" href="neon-animation/animations/scale-up-animation.html">
  <link rel="import" href="neon-animation/animations/fade-out-animation.html">

</head>
<body>
  <dom-module id="my-el">
    <template>
      <button on-click="open">Open Dialog</button>
      <paper-dialog
        id="dialog"
        entry-animation="scale-up-animation"
        exit-animation="fade-out-animation"
        modal
       >
        <h2>Header</h2>
        <div>Dialog body</div>
      </paper-dialog>
    </template>
    <script>
      class MyEl extends Polymer.Element {
        static get is() { return 'my-el' }

    constructor() {
      super();
        }

        open() {
          console.log('opening...');
          this.$.dialog.open();
          console.log('opened!');
        }

      }

      customElements.define(MyEl.is, MyEl);
    </script>
  </dom-module>

  <my-el></my-el>
</body>
</html>

编辑

注意,对于特定版本的聚合物,您可以使用

代码语言:javascript
复制
<base href="//polygit.org/polymer2.0+:master/components/">

代码语言:javascript
复制
<base href="//polygit.org/polymer1.0+:master/components/">

等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46032634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档