我正在尝试运行http://itshackademic.com/static/codelabs/3-polymer-build-mobile/处给出的教程示例。最终的代码在Chrome上运行良好。但是,在Firefox 33.0.3上<paper-input on-change="{{add}}"/>
没有调用适当的函数。代码在下面,正如我所提到的那样按&#34; Return&#34;而在纸张输入上没有触发功能。我检查了几个类似的问题(this和this),但那里的解决方案并不适用。
代码在Chrome上运行正常。 有什么建议吗?
的index.html:
<!doctype html>
<html>
<head>
<title>PolymerMobileCodelab</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="codelab-app.html">
</head>
<body unresolved>
<codelab-app></codelab-app>
</body>
</html>
程式码实验室-app.html:
<!-- New polymer element -->
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/font-roboto/roboto.html">
<link rel="import" href="bower_components/core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="bower_components/core-header-panel/core-header-panel.html">
<link rel="import" href="bower_components/core-toolbar/core-toolbar.html">
<link rel="import" href="bower_components/core-icons/core-icons.html">
<link rel="import" href="bower_components/core-localstorage/core-localstorage.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/paper-fab/paper-fab.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">
<link rel="import" href="bower_components/paper-checkbox/paper-checkbox.html">
<polymer-element name="codelab-app">
<template>
<link rel="stylesheet" href="styles.css">
<core-drawer-panel id="drawerPanel" responsiveWidth="641px">
<core-header-panel drawer>
<core-toolbar>Menu</core-toolbar>
</core-header-panel>
<core-header-panel main>
<core-toolbar>
<paper-icon-button icon="menu" core-drawer-toggle>
</paper-icon-button>
<span flex>My notes</span>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<paper-fab icon="icons:add" on-click="{{showNewNoteInput}}"></paper-fab>
</core-toolbar>
<div class="content">
<paper-input id="newNoteInput"
floatingLabel
on-change="{{add}}"
value="{{newNote}}"
label="Add a new note"></paper-input>
<template repeat="{{data}}" >
<div center horizontal layout class="item">
<paper-checkbox checked="{{done}}" on-change="{{dataChanged}}"></paper-checkbox>
<div flex class="card">
<p>{{body}}</p>
</div>
<!-- paper-icon-button icon="clear" on-click="{{remove}}"></paper-icon-button -->
</div>
</template>
</div>
</core-header-panel>
</core-drawer-panel>
<core-localstorage id="storage" name="codelab-app-storage" value="{{data}}"></core-localstorage>
</template>
<script>
Polymer({
data: [],
ready: function() {
this.$.newNoteInput.style.display = 'none';
},
showNewNoteInput: function() {
this.$.newNoteInput.style.display = 'block';
},
add: function() {
if (this.newNote) {
this.data.unshift({
body: this.newNote,
done: false
});
this.$.newNoteInput.style.display = 'none';
this.$.newNoteInput.value = null;
}
},
remove: function() {
},
dataChanged: function() {
this.$.storage.save();
}
});
</script>
</polymer-element>
答案 0 :(得分:1)
这是Polymer方面的一个问题。它已于current version解决。
change()
动作在paper-input.html中声明,并且有条件执行并阻止在旧浏览器上触发。
答案 1 :(得分:0)
您可以随时扩展纸张输入并在其原型上使用attributenameChanged回调。通过&#34; app-global&#34;传递它。如果你需要的话 但是,是的,我想它不应该是这样的。
我将尝试重现/修复/破解它并返回。