github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/themes/wind/static/libs/vue-1.0.24/src/directives/public/model/radio.js (about)

     1  import { toNumber, looseEqual } from '../../../util/index'
     2  
     3  export default {
     4  
     5    bind () {
     6      var self = this
     7      var el = this.el
     8  
     9      this.getValue = function () {
    10        // value overwrite via v-bind:value
    11        if (el.hasOwnProperty('_value')) {
    12          return el._value
    13        }
    14        var val = el.value
    15        if (self.params.number) {
    16          val = toNumber(val)
    17        }
    18        return val
    19      }
    20  
    21      this.listener = function () {
    22        self.set(self.getValue())
    23      }
    24      this.on('change', this.listener)
    25  
    26      if (el.hasAttribute('checked')) {
    27        this.afterBind = this.listener
    28      }
    29    },
    30  
    31    update (value) {
    32      this.el.checked = looseEqual(value, this.getValue())
    33    }
    34  }