index.js 759 B

1234567891011121314151617181920212223242526272829303132
  1. import { createNamespace } from '../utils';
  2. import { CheckboxMixin } from '../mixins/checkbox';
  3. var _createNamespace = createNamespace('radio'),
  4. createComponent = _createNamespace[0],
  5. bem = _createNamespace[1];
  6. export default createComponent({
  7. mixins: [CheckboxMixin({
  8. bem: bem,
  9. role: 'radio',
  10. parent: 'vanRadio'
  11. })],
  12. computed: {
  13. currentValue: {
  14. get: function get() {
  15. return this.parent ? this.parent.value : this.value;
  16. },
  17. set: function set(val) {
  18. (this.parent || this).$emit('input', val);
  19. }
  20. },
  21. checked: function checked() {
  22. return this.currentValue === this.name;
  23. }
  24. },
  25. methods: {
  26. toggle: function toggle() {
  27. this.currentValue = this.name;
  28. }
  29. }
  30. });