New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

表单元素radio value无法绑定 #66

Closed
lyf911010 opened this Issue Mar 13, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@lyf911010

lyf911010 commented Mar 13, 2018

在使用input type=radio时候,编译之后,radio标签中的value值一直为空,不知道如何绑定

@anchengjian

This comment has been minimized.

Member

anchengjian commented Mar 13, 2018

建议直接用 radio-group :

<template>
  <div>
    <radio-group class="radio-group" @change="radioChange">
      <label class="radio" v-for="(item, index) in items" :key="item.name">
        <radio :value="item.name" :checked="item.checked"/> {{item.value}}
      </label>
    </radio-group>
  </div>
</template>

<script>
export default {
  data () {
    return {
      items: [
        {name: 'USA', value: '美国'},
        {name: 'CHN', value: '中国', checked: 'true'},
        {name: 'BRA', value: '巴西'},
        {name: 'JPN', value: '日本'},
        {name: 'ENG', value: '英国'},
        {name: 'TUR', value: '法国'}
      ]
    }
  },
  methods: {
    radioChange (e) {
      console.log('radio发生change事件,携带value值为:', e.target.value)
    }
  }
}

</script>

参见微信文档: https://mp.weixin.qq.com/debug/wxadoc/dev/component/radio.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment