mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
refactor(components): [switch] deprecate value prop (#8335)
This commit is contained in:
parent
4ac10cfb97
commit
10cad1d072
@ -83,7 +83,15 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
getCurrentInstance,
|
||||
nextTick,
|
||||
onMounted,
|
||||
ref,
|
||||
watch,
|
||||
} from 'vue'
|
||||
import { isPromise } from '@vue/shared'
|
||||
import { addUnit, debugWarn, isBoolean, throwError } from '@element-plus/utils'
|
||||
import ElIcon from '@element-plus/components/icon'
|
||||
@ -94,6 +102,7 @@ import {
|
||||
UPDATE_MODEL_EVENT,
|
||||
} from '@element-plus/constants'
|
||||
import {
|
||||
useDeprecated,
|
||||
useDisabled,
|
||||
useFormItem,
|
||||
useFormItemInputId,
|
||||
@ -114,15 +123,28 @@ export default defineComponent({
|
||||
emits: switchEmits,
|
||||
|
||||
setup(props, { emit }) {
|
||||
const vm = getCurrentInstance()!
|
||||
const { formItem } = useFormItem()
|
||||
const switchSize = useSize()
|
||||
const switchDisabled = useDisabled(computed(() => props.loading))
|
||||
const ns = useNamespace('switch')
|
||||
|
||||
useDeprecated(
|
||||
{
|
||||
from: '"value"',
|
||||
replacement: '"model-value" or "v-model"',
|
||||
scope: COMPONENT_NAME,
|
||||
version: '2.3.0',
|
||||
ref: 'https://element-plus.org/en-US/component/switch.html#attributes',
|
||||
type: 'Attribute',
|
||||
},
|
||||
computed(() => !!vm.vnode.props?.value)
|
||||
)
|
||||
|
||||
const { inputId } = useFormItemInputId(props, {
|
||||
formItemContext: formItem,
|
||||
})
|
||||
|
||||
const switchSize = useSize()
|
||||
const isModelValue = ref(props.modelValue !== false)
|
||||
const input = ref<HTMLInputElement>()
|
||||
const core = ref<HTMLSpanElement>()
|
||||
|
@ -9,7 +9,7 @@ type DeprecationParam = {
|
||||
scope: string
|
||||
version: string
|
||||
ref: string
|
||||
type?: 'API' | 'Slot' | 'Event'
|
||||
type?: 'API' | 'Attribute' | 'Event' | 'Slot'
|
||||
}
|
||||
|
||||
export const useDeprecated = (
|
||||
@ -22,7 +22,7 @@ export const useDeprecated = (
|
||||
if (val) {
|
||||
debugWarn(
|
||||
scope,
|
||||
`${type} ${from} is about to be deprecated in version ${version}, please use ${replacement} instead.
|
||||
`[${type}] ${from} is about to be deprecated in version ${version}, please use ${replacement} instead.
|
||||
For more detail, please visit: ${ref}
|
||||
`
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user