paper-radio-group仅在第二次点击时进行选择

时间:2017-05-03 08:13:10

标签: javascript polymer

这可能是非常简单的事情,但我现在无法弄明白。我有一个带有各种按钮的聚合物纸 - 收音机组,但是在第二次点击之前不会进行选择。

<paper-radio-group selected="{{radioSelected}}" on-change="viewChanger">
    <paper-radio-button name="none">None</paper-radio-button>
    <paper-radio-button name="sidebyside">Side by side</paper-radio-button>
    <paper-radio-button name="popup">Pop-up</paper-radio-button>
</paper-radio-group>

和JS:

Polymer({
  is: 'x-menu',
  properties: {
      radioSelected: {
         type: String,
         value: "none"
      }
  },
  viewChanger: function() {
    console.log(this.radioSelected);
  }
});

感谢您的帮助。我是Polymer的新手。

1 个答案:

答案 0 :(得分:1)

更好地尝试:

<paper-radio-group selected="{{radioSelected}}">
  <paper-radio-button name="none">None</paper-radio-button>
  <paper-radio-button name="sidebyside">Side by side</paper-radio-button>
  <paper-radio-button name="popup">Pop-up</paper-radio-button>
</paper-radio-group>

你的JS:

Polymer({
  is: 'x-menu',
  properties: {

    radioSelected: {
      type: String,
      value: "none",
      observer: '_radioGroupChanged'
    }
  },

  _radioGroupChanged: function(radioSelected) {
    console.log(radioSelected);
  }
});