Commit 3dad2deb5474e95a70d164e20f3e5b54a0dd74d7

Authored by ly525
1 parent 0ddb398e

fix(plugin) switch between radio and checkbox

front-end/h5/src/components/plugins/lbp-form-radio-group.js
@@ -39,7 +39,17 @@ export default { @@ -39,7 +39,17 @@ export default {
39 }, 39 },
40 computed: { 40 computed: {
41 value_ () { 41 value_ () {
42 - return this.type === 'radio' ? this.value : this.value.join(',') 42 + if (this.type === 'radio') {
  43 + return this.value
  44 + } else {
  45 + const value = (Array.isArray(this.value) && this.value) || []
  46 + return value.join(',')
  47 + }
  48 + }
  49 + },
  50 + watch: {
  51 + type (type) {
  52 + this.value = type === 'radio' ? '' : []
43 } 53 }
44 }, 54 },
45 editorConfig: { 55 editorConfig: {
@@ -125,6 +135,9 @@ export default { @@ -125,6 +135,9 @@ export default {
125 this.uuid = this.$el.dataset.uuid 135 this.uuid = this.$el.dataset.uuid
126 }, 136 },
127 methods: { 137 methods: {
  138 + /**
  139 + * @param {String, Number} val radioValue or checkboxValue
  140 + */
128 onChange (val) { 141 onChange (val) {
129 switch (this.type) { 142 switch (this.type) {
130 case 'radio': 143 case 'radio':