修复组件打包后出现问题

This commit is contained in:
吕金泽 2022-03-25 17:14:28 +08:00
parent bb91e96638
commit 43976afbee
5 changed files with 36 additions and 9 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<el-date-picker <el-date-picker
v-model="modelValue" v-model="selectValue"
:type="type" :type="type"
:format="format" :format="format"
:value-format="valueFormat" :value-format="valueFormat"
@ -14,6 +14,7 @@
<script setup> <script setup>
import { watch, ref } from 'vue' import { watch, ref } from 'vue'
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const selectValue = ref('')
const props = defineProps({ const props = defineProps({
modelValue: String, modelValue: String,
type: String, type: String,
@ -35,8 +36,13 @@
}, },
props: Object props: Object
}) })
const valueFormat = ref(props.format)
selectValue.value = props.modelValue
watch(() => props.modelValue, (value) => { watch(() => props.modelValue, (value) => {
selectValue.value = value
})
const valueFormat = ref(props.format)
watch(selectValue, (value) => {
emit('update:modelValue', value) emit('update:modelValue', value)
}) })
</script> </script>

View File

@ -1,10 +1,11 @@
<template> <template>
<el-input v-model="modelValue" :type="type" :placeholder="placeholder || (itemLabel && '请输入' + itemLabel)" v-bind="props.props" /> <el-input v-model="selectValue" :type="type" :placeholder="placeholder || (itemLabel && '请输入' + itemLabel)" v-bind="props.props" />
</template> </template>
<script setup> <script setup>
import { watch } from 'vue' import {ref, watch} from 'vue'
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const selectValue = ref('')
const props = defineProps({ const props = defineProps({
modelValue: String, modelValue: String,
itemLabel: String, itemLabel: String,
@ -12,7 +13,11 @@
type: String, type: String,
props: Object props: Object
}) })
selectValue.value = props.modelValue
watch(() => props.modelValue, (value) => { watch(() => props.modelValue, (value) => {
selectValue.value = value
})
watch(selectValue, (value) => {
emit('update:modelValue', value) emit('update:modelValue', value)
}) })
</script> </script>

View File

@ -1,6 +1,6 @@
<template> <template>
<el-radio-group <el-radio-group
v-model="modelValue" v-model="selectValue"
:size="size" :size="size"
:disabled="disabled" :disabled="disabled"
:text-color="textColor" :text-color="textColor"
@ -22,6 +22,7 @@
const emit = defineEmits(['update:modelValue', 'change']) const emit = defineEmits(['update:modelValue', 'change'])
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const selectValue = ref('')
const props = defineProps({ const props = defineProps({
modelValue: String | Number | Boolean, modelValue: String | Number | Boolean,
type: String, type: String,
@ -59,6 +60,8 @@
} }
}) })
selectValue.value = props.modelValue
const options = ref([]) const options = ref([])
if(props.type){ if(props.type){
@ -83,8 +86,10 @@
function change(value){ function change(value){
emit('change', value) emit('change', value)
} }
watch(() => props.modelValue, (value) => { watch(() => props.modelValue, (value) => {
selectValue.value = value
})
watch(selectValue, (value) => {
emit('update:modelValue', value) emit('update:modelValue', value)
}) })
</script> </script>

View File

@ -1,6 +1,6 @@
<template> <template>
<el-switch <el-switch
v-model="modelValue" v-model="selectValue"
:active-value="activeValue" :active-value="activeValue"
:inactive-value="inactiveValue" :inactive-value="inactiveValue"
v-bind="props.props" v-bind="props.props"
@ -8,8 +8,9 @@
</template> </template>
<script setup> <script setup>
import { watch } from 'vue' import {ref, watch} from 'vue'
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const selectValue = ref(false)
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: Boolean, type: Boolean,
@ -19,7 +20,12 @@
inactiveValue: Boolean | String | Number, inactiveValue: Boolean | String | Number,
props: Object props: Object
}) })
selectValue.value = props.modelValue
watch(() => props.modelValue, (value) => { watch(() => props.modelValue, (value) => {
selectValue.value = value
})
watch(selectValue, (value) => {
emit('update:modelValue', value) emit('update:modelValue', value)
}) })
</script> </script>

View File

@ -1,10 +1,11 @@
<template> <template>
<treeselect v-model="modelValue" :options="options" :key="modelValue" :placeholder="placeholder || (itemLabel && '请选择' + itemLabel)" :show-count="true" v-bind="props.props" /> <treeselect v-model="selectValue" :options="options" :key="modelValue" :placeholder="placeholder || (itemLabel && '请选择' + itemLabel)" :show-count="true" v-bind="props.props" />
</template> </template>
<script setup> <script setup>
import { ref, getCurrentInstance, watch } from "vue" import { ref, getCurrentInstance, watch } from "vue"
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const selectValue = ref(null)
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
@ -21,7 +22,11 @@
props: Object props: Object
}) })
selectValue.value = props.modelValue
watch(() => props.modelValue, (value) => { watch(() => props.modelValue, (value) => {
selectValue.value = value
})
watch(selectValue, (value) => {
emit('update:modelValue', value) emit('update:modelValue', value)
}) })