| | |
| | | :class="className" |
| | | > |
| | | <AtSwitch :title="itemRes.label" /> |
| | | <radio-group @change="evt => handleChange(evt.detail.value)"> |
| | | <label> |
| | | <radio |
| | | value="true" |
| | | :checked="itemRes.formData[itemRes.name]" |
| | | >{{checkedLabel}}</radio> |
| | | </label> |
| | | <label> |
| | | <radio |
| | | value="false" |
| | | :checked="!itemRes.formData[itemRes.name]" |
| | | >{{uncheckedLabel}}</radio> |
| | | </label> |
| | | </radio-group> |
| | | <view class="c-switch-radio-group"> |
| | | <view |
| | | class="c-switch-radio-item" |
| | | @tap="evt => handleChange(true)" |
| | | > |
| | | <text |
| | | class="c-switch-radio-icon" |
| | | :class="current === true ? 'checked' : ''" |
| | | > |
| | | <AtIcon value="check" /> |
| | | </text> |
| | | <text>{{checkedLabel}}</text> |
| | | </view> |
| | | <view |
| | | class="c-switch-radio-item" |
| | | @tap="evt => handleChange(false)" |
| | | > |
| | | <text |
| | | class="c-switch-radio-icon" |
| | | :class="current === false ? 'checked' : ''" |
| | | > |
| | | <AtIcon value="check" /> |
| | | </text> |
| | | <text>{{uncheckedLabel}}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { AtSwitch } from 'taro-ui-vue'; |
| | | import { AtSwitch, AtIcon } from 'taro-ui-vue'; |
| | | import './cSwitch.scss'; |
| | | |
| | | export default { |
| | | name: 'CSwitchRadio', |
| | | components: { AtSwitch }, |
| | | components: { |
| | | AtSwitch, |
| | | AtIcon, |
| | | }, |
| | | props: { |
| | | // 表单数据资源(表单组件内部机制专用) |
| | | itemRes: Object, |
| | |
| | | } |
| | | return className; |
| | | }, |
| | | current() { |
| | | return this.itemRes.formData[this.itemRes.name]; |
| | | }, |
| | | }, |
| | | methods: { |
| | | handleChange(value) { |
| | | this.itemRes.onChange(JSON.parse(value)); |
| | | this.itemRes.onChange(value); |
| | | }, |
| | | }, |
| | | }; |