Polymer-3.x ..无法通过对象引用将JSON的值绑定到纸张切换按钮

时间:2019-11-28 07:19:47

标签: polymer-3.x

//Properties
drivingEligibility:{type:Boolean,notify:true}
//EventListener 
driving(){
if (this.$.drivingEligibility.checked == true) {this.drivingEligibility = true;
       console.log(" drivingEligibility.value in if :" +this.drivingEligibility);
     }else{
        this.drivingEligibility = false;
       console.log(" drivingEligibility.value in else :" +this.drivingEligibility);
     }
   }
HTML Code
<paper-toggle-button name="drivingEligibility" id="drivingEligibility" class="float-right" checked="{{drivingEligibility}}" on-change="driving"></paper-toggle-button>

数据以正确的格式保存。.但数据未绑定到元素(纸张切换按钮)

1 个答案:

答案 0 :(得分:0)

您不需要在函数中设置drivingEligibility的值。它已经绑定。在:

<paper-toggle-button name="drivingEligibility" id="drivingEligibility" class="float-right" checked="{{drivingEligibility}}" on-change="driving"></paper-toggle-button>

Demo