我希望通过在<paper-input>
字段中输入文字来触发观察者。
在邮政编码字段中输入文字时,我希望看到输入的文字记录到控制台。相反,我在控制台中看不到任何内容。
我做错了什么?
http://jsbin.com/xahobojixe/1/edit?html,console,output<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<base href="//polygit.org/polymer+:master/components/">
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer-element.html">
<link rel="import" href="paper-input/paper-input.html">
</head>
<body>
<dom-module id="my-el">
<template>
<paper-input label="simple character counter" char-counter value="{{zipCode}}"></paper-input>
[[zipCode]]
</template>
<script>
class MyEl extends Polymer.Element {
static get is() {
return 'my-el';
}
static get properties() {
/**/
return {
properties: {
zipCode: {
type: String,
notify: true,
observer: '_zipCodeChanged',
},
},
};
}
constructor() {
super();
}
/**/
ready() {
super.ready();
}
_zipCodeChanged(s) {
console.log('zip-code', s);
console.log('zip-code-this', this.zipCode);
}
}
window.customElements.define(MyEl.is, MyEl);
</script>
</dom-module>
<my-el></my-el>
</body>
</html>
答案 0 :(得分:2)
您的properties
getter看起来不正确,因为它包含一个名为properties
的属性。吸气剂应该是:
static get properties() {
return {
zipCode: {
type: String,
notify: true,
observer: '_zipCodeChanged',
},
}
}