作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
将核心项目放在子菜单中时,访问核心项目标签时遇到问题。
这是一个例子。
<polymer-element name="page-element">
<template>
<style>
</style>
<core-scaffold>
<core-header-panel navigation flex>
<core-toolbar id="navheader">
<span>Menu</span>
</core-toolbar>
<core-menu selected="0" selectedItem="{{item}}">
<core-item icon="home" label="item1"></core-item>
<core-item icon="info" label="item2"></core-item>
<core-submenu icon="check-circle" label="submenu1">
<core-item label="item3"></core-item>
<core-item label="item4"></core-item>
</core-submenu>
</core-menu>
</core-header-panel>
<span tool>Title</span>
<div class="content">
{{item.label}}
</div>
</core-scaffold>
</template>
<script type="application/dart" src="page_element.dart"></script>
</polymer-element>
import 'package:polymer/polymer.dart';
import 'package:core_elements/core_item.dart';
@CustomTag('page-element')
class PageElement extends PolymerElement {
@published CoreItem item;
PageElement.created() : super.created() {
}
}
最佳答案
<link rel="import" href="../../packages/polymer/polymer.html">
<link rel="import" href="../../packages/core_elements/core_scaffold.html">
<link rel="import" href="../../packages/core_elements/core_header_panel.html">
<link rel="import" href="../../packages/core_elements/core_toolbar.html">
<link rel="import" href="../../packages/core_elements/core_menu.html">
<link rel="import" href="../../packages/core_elements/core_item.html">
<link rel="import" href="../../packages/core_elements/core_submenu.html">
<polymer-element name="app-element">
<template>
<style>
:host {
display: block;
}
</style>
<core-scaffold>
<core-header-panel navigation flex>
<core-toolbar id="navheader">
<span>Menu</span>
</core-toolbar>
<core-menu selected="0" selectedItem="{{item}}">
<core-item icon="home" label="item1"></core-item>
<core-item icon="info" label="item2"></core-item>
<!-- the submenu has its own selected state -->
<core-submenu icon="check-circle" label="submenu1" selectedItem="{{subItem}}">
<core-item label="item3"></core-item>
<core-item label="item4"></core-item>
</core-submenu>
</core-menu>
</core-header-panel>
<span tool>Title</span>
<div class="content">
<div>resolved: {{subItem != null ? subItem.label : item.label}}</div> <!-- this is probably what you want -->
<div>item: {{item.label}}</div> <!-- these are just for debugging purposes -->
<div>subItem: {{subItem.label}}</div>
</div>
</core-scaffold>
</template>
<script type="application/dart" src="app_element.dart"></script>
</polymer-element>
@published var item; // don't use CoreItem as type here because this throws if you select 'subMenu1' (is not a 'CoreItem')
@published var subItem;
关于dart - polymer Dart 芯子菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26329310/
我是一名优秀的程序员,十分优秀!