Polymer 1.x:帮助让这个JSBin呈现<paper-header-panel>和<paper-toolbar>

时间:2015-10-11 18:42:27

标签: polymer polymer-1.0 paper-elements

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

This JSBin doesn't render its contents。它不显示:

  • 标题 部分 - <paper-toolbar>文字(即"Header")或
  • 内容面板 部分 - <div>元素(即"Content goes here...")。
  

我做错了什么?请提供一个有效的JSBin示例。

注意: Per this link<paper-header-panel>要求主持人拥有height

代码

<!DOCTYPE html>
<html>  
<head>
  <meta charset="utf-8">
  <title>Polymer Bin</title>
  <base href="http://element-party.xyz/">
  <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="all-elements.html">
</head>
<body class="fullbleed layout vertical">
<x-element></x-element>
<dom-module id="x-element">
  <template>
    <style>
    </style>
    <paper-header-panel class="flex">
      <paper-toolbar>Header</paper-toolbar>
      <div>Content goes here...</div>
    </paper-header-panel>   
  </template>
  <script>
    (function(){
      Polymer({
        is: 'x-element'
      });
    })();
  </script>
</dom-module>
</body>
</html>

3 个答案:

答案 0 :(得分:1)

http://jsbin.com/kabede/5/edit?html,output

变化:

  1. 来自rawgit的webcomponents而不是bower_components
  2. <span class="title">使标题可见
  3. style =“width:100%; height:100%;”在元素上看到它的内容

答案 1 :(得分:0)

接受的答案代码
#app/controllers/projects_controller.rb
class ProjectsController < ApplicationController
   def index
       @users = Project.all_users
   end
end

#app/models/project.rb
class Project < ActiveRecord::Base
   scope :all_users, -> { joins(:users) } #-> this needs to be tested
end

#app/views/projects/index.haml
- @users.each do |user|
  = user.name

答案 2 :(得分:0)

Here is the minimum markup necessary to answer the question

http://jsbin.com/jocinasovo/edit?html,output

更改

  1. 使用:host
  2. 添加了样式
  3. 只需要height而不是width
  4. 无需从bower_componentsper this link)切换到rawgit CDN
  5. .flex
  6. 无需<paper-header-panel>课程

    注意: Per this link<paper-header-panel>要求主持人拥有height

    代码

    <!DOCTYPE html>
    <html>  
    <head>
      <meta charset="utf-8">
      <title>Polymer Bin</title>
      <base href="http://element-party.xyz/">
      <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
      <link rel="import" href="all-elements.html">
    </head>
    <body class="fullbleed layout vertical">
    <x-element></x-element>
      <dom-module id="x-element">
      <template>
        <style>
          :host {
            height: 100%
          }
        </style>
        <paper-header-panel>
          <paper-toolbar><span>Header</span></paper-toolbar>
          <div>Content goes here...</div>
        </paper-header-panel>   
      </template>
      <script>
        (function(){
          Polymer({
            is: 'x-element'
          });
        })();
      </script>
    </dom-module>
    </body>
    </html>