gpt4 book ai didi

dart - 聚合物数据绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-12-03 03:13:24 24 4
gpt4 key购买 nike

我正在尝试获取 <core-menu>与 Dart 合作。它显示正常,但 selectedIndex属性未更新。
以下代码适用于 PolymerJS,但在 Dart 版本中 selectedIndex未更新(​​<core-menu selectedIndex="{{selectedMenuIndex}}"...>)

我希望 {{selectedMenuIndex}}可在 <core-animated-pages> 中获得标记但 {{selectedMenuIndex}}变量为空。它没有得到更新。 .dart文件的 var 声明如下:

@observable num selectedMenuIndex = 0;

这是 .html 代码:

<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/core_elements/core_drawer_panel.html">
<link rel="import" href="packages/core_elements/core_menu.html">
<link rel="import" href="packages/core_elements/core_selector.html">
<link rel="import" href="packages/core_elements/core_item.html">
<link rel="import" href="packages/core_elements/core_icon_button.html">
<link rel="import" href="packages/paper_elements/paper_icon_button.html">
<link rel="import" href="packages/core_elements/core_toolbar.html">
<link rel="import" href="packages/core_elements/core_header_panel.html">
<link rel="import" href="packages/paper_elements/core_animated_pages.html">

<polymer-element name="test-app">

<template>
<!-- [START html] -->
<core-drawer-panel id="drawerPanel">

<core-header-panel drawer>
<core-toolbar id="navheader'">
<span>Menu</span>
</core-toolbar>
<core-menu selected="0" selectedIndex="{{selectedMenuIndex}}" id="coreMenu" on-click="{{togglePanelButton}}">
<core-item icon="settings" label="One"></core-item>
<core-item icon="search" label="Two"></core-item>
</core-menu>
</core-header-panel>

<core-header-panel main>
<core-toolbar id="mainheader">
<paper-icon-button id="navicon" icon="menu" on-click="{{ togglePanelButton }}"></paper-icon-button>
<span flex>Title</span>
</core-toolbar>
<core-animated-pages selected="{{selectedMenuIndex}}" notap id="core_animated_pages" transitions="slide-from-right">
<section class="content-section">
Section 1
</section>
<section class="content-section">
Section 2
</section>
</core-animated-pages>
</core-header-panel>

</core-drawer-panel>
<!-- [END html]-->
</template>

<script type="application/dart" src="testapp.dart"></script>
</polymer-element>

你们是不是也有数据问题,还是我做错了什么?

更新:我在这里提交了一个错误报告:
https://code.google.com/p/dart/issues/detail?id=19794

最佳答案

我从 Dart Polymer 小组得到了答案:
https://code.google.com/p/dart/issues/detail?id=19794

似乎与 core_elements 的 2-way 绑定(bind)存在问题。

关于dart - 聚合物数据绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24525317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com