点击后如何更改按钮内容? 在函数中我可以更改绑定值吗?
<dom-module id="my-facebook-login-button">
<template>
<paper-button on-click="facebookLogin">{{loginButton}}</paper-button>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'my-facebook-login-button',
properties: {
loginButton: {
type: String,
value: 'Login with facebook',
notify: true
}
},
facebookLogin: function() {
var ref = new Firebase("https://sizzling-heat-4021.firebaseio.com/");
ref.authWithOAuthPopup("facebook", function (error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
app.user=authData;
this.loginButton='Loged in';
}
});
},
});
})();
</script>
this.loginButton =&#39; Loged in&#39;不要改变按钮内容
答案 0 :(得分:0)
facebookLogin: function() {
var ref = new Firebase("https://sizzling-heat-4021.firebaseio.com/");
ref.authWithOAuthPopup("facebook", function (error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
app.user=authData;
this.loginButton='Logged in';
}
}.bind(this));
},