0
我試圖適應聚合物1.0中找到的工作表單,以便在聚合物2.0上工作,但這兩種數據綁定似乎不起作用。屬性不會更新輸入更改
我的模板:
<paper-input>
<label>Username</label>
<iron-input bind-value={{formData.username}}><input id="username" type="text" value="{{formData::input}}"></iron-input>
</paper-input>
<paper-input>
<label>Password</label>
<iron-input bind-value={{formData.password}}><input id="password" type="password" value="{{formData::input}}"></iron-input>
</paper-input>
<div class="wrapper-btns">
<paper-button raised class="primary" on-tap="postLogin">Log In</paper-button>
<paper-button class="link" on-tap="postRegister">Sign Up</paper-button>
</div>
我的行爲:
class MyLogin extends Polymer.Element {
static get is() { return 'my-login'; }
static get properties() {
return {
storedUser: Object,
error: String,
formData: {
type: Object,
value: {},
},
}
}
_setReqBody() {
console.log(this.formData) // <--- THIS LINE!
this.$.registerLoginAjax.body = this.formData;
}
postLogin() {
this.$.registerLoginAjax.url = 'http://localhost:3001/sessions/create';
this._setReqBody();
this.$.registerLoginAjax.generateRequest();
}
}
的指示線將始終打印未定義雖然。我究竟做錯了什麼?
下面是完整的代碼:https://github.com/lpfjustino/PolymerQuickstart/blob/master/web/src/my-login.html 而這裏的代碼我的依據是: https://auth0.com/blog/build-your-first-app-with-polymer-and-web-components/