<app-toolbar>的主标题无法正常工作?

时间:2016-11-02 05:46:03

标签: polymer material-design polymer-1.0 web-component google-web-component

我目前正在使用app-layout元素(版本0.10.4),特别是app-toolbar。

使用&#34;主标题&#34;创建div时属性与之相关,它不会起作用。&#34;我不完全确定,如果它可能是我导入的内容。

<link rel="import" href="bower_components/paper-styles/paper-styles.html">
<link rel="import" href="bower_components/iron-icons/iron-icons.html">

<link rel="import" href="bower_components/app-layout/app-layout.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">

或者可能是我使用app-toolbar错误。

<body>
    <app-header-layout>
        <app-header effects="waterfall" reveals>
            <app-toolbar>
                <paper-icon-button icon="menu"></paper-icon-button>
            </app-toolbar>
        </app-header>
        <main>
        </main>
    </app-header-layout>
</body>

感谢所有反馈,谢谢!

1 个答案:

答案 0 :(得分:0)

你的进口对我来说是正确的。鉴于docs并未完全描述main-title的作用,您可能会对该属性采取错误行为。请注意,main-title会在工具栏中展开标题的宽度。请参阅下面的演示。

&#13;
&#13;
<head>
  <base href="https://polygit.org/polymer+1.7.0/components/">
  <script src="webcomponentsjs/webcomponents-lite.min.js"></script>
  <link rel="import" href="polymer/polymer.html">
  <link rel="import" href="iron-icons/iron-icons.html">
  <link rel="import" href="paper-icon-button/paper-icon-button.html">

  <link rel="import" href="app-layout/app-layout.html">
</head>
<body>
  <style is="custom-style">
    app-toolbar {
      background-color: #4285f4;
      color: white;
      margin-bottom: 10px;
    }
    .my-title {
      border: solid 1px red;
    }
  </style>

  <app-toolbar>
    <paper-icon-button icon="menu"></paper-icon-button>
    <div class="my-title" main-title>With <code>main-title</code></div>
    <paper-icon-button icon="account-circle"></paper-icon-button>
  </app-toolbar>
  
  <app-toolbar>
    <paper-icon-button icon="menu"></paper-icon-button>
    <div class="my-title">Without <code>main-title</code></div>
    <paper-icon-button icon="account-circle"></paper-icon-button>
  </app-toolbar>
</body>
&#13;
&#13;
&#13;