fix: support vue3.1
parent
b45a6250de
commit
93c2bc1552
|
@ -42,7 +42,7 @@ const AutoComplete = defineComponent({
|
|||
OptGroup: { ...OptGroup, name: 'AAutoCompleteOptGroup' },
|
||||
setup(props, { slots }) {
|
||||
warning(
|
||||
!('dataSource' in props || 'dataSource' in slots),
|
||||
!(props.dataSource !== undefined || 'dataSource' in slots),
|
||||
'AutoComplete',
|
||||
'`dataSource` is deprecated, please use `options` instead.',
|
||||
);
|
||||
|
|
|
@ -123,7 +123,7 @@ export default defineComponent({
|
|||
{ immediate: true },
|
||||
);
|
||||
watchEffect(() => {
|
||||
if ('activeKey' in props) {
|
||||
if (props.activeKey !== undefined) {
|
||||
let keys = [];
|
||||
const menuInfo = props.activeKey
|
||||
? (keyMapStore.value[props.activeKey] as UnwrapRef<StoreMenuInfo>)
|
||||
|
@ -194,7 +194,7 @@ export default defineComponent({
|
|||
selectedKeys: newSelectedKeys,
|
||||
};
|
||||
if (!shallowEqual(newSelectedKeys, mergedSelectedKeys.value)) {
|
||||
if (!('selectedKeys' in props)) {
|
||||
if (props.selectedKeys === undefined) {
|
||||
mergedSelectedKeys.value = newSelectedKeys;
|
||||
}
|
||||
emit('update:selectedKeys', newSelectedKeys);
|
||||
|
@ -223,11 +223,10 @@ export default defineComponent({
|
|||
);
|
||||
|
||||
const changeActiveKeys = (keys: Key[]) => {
|
||||
if ('activeKey' in props) {
|
||||
emit('update:activeKey', keys[keys.length - 1]);
|
||||
} else {
|
||||
if (props.activeKey === undefined) {
|
||||
activeKeys.value = keys;
|
||||
}
|
||||
emit('update:activeKey', keys[keys.length - 1]);
|
||||
};
|
||||
const disabled = computed(() => !!props.disabled);
|
||||
const isRtl = computed(() => direction.value === 'rtl');
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
computed,
|
||||
onMounted,
|
||||
nextTick,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
|
@ -27,7 +28,6 @@ const switchProps = {
|
|||
checkedChildren: PropTypes.any,
|
||||
unCheckedChildren: PropTypes.any,
|
||||
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
defaultChecked: PropTypes.looseBool,
|
||||
autofocus: PropTypes.looseBool,
|
||||
loading: PropTypes.looseBool,
|
||||
checked: PropTypes.looseBool,
|
||||
|
@ -59,6 +59,14 @@ const Switch = defineComponent({
|
|||
'`value` is not validate prop, do you mean `checked`?',
|
||||
);
|
||||
});
|
||||
const checked = ref(props.checked !== undefined ? !!props.checked : !!attrs.defaultChecked);
|
||||
|
||||
watch(
|
||||
() => props.checked,
|
||||
() => {
|
||||
checked.value = !!props.checked;
|
||||
},
|
||||
);
|
||||
|
||||
const configProvider = inject('configProvider', defaultConfigProvider);
|
||||
const { getPrefixCls } = configProvider;
|
||||
|
@ -75,9 +83,6 @@ const Switch = defineComponent({
|
|||
const prefixCls = computed(() => {
|
||||
return getPrefixCls('switch', props.prefixCls);
|
||||
});
|
||||
const checked = computed(() => {
|
||||
return 'checked' in props ? !!props.checked : !!props.defaultChecked;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
|
@ -91,6 +96,9 @@ const Switch = defineComponent({
|
|||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
if (props.checked === undefined) {
|
||||
checked.value = check;
|
||||
}
|
||||
emit('update:checked', check);
|
||||
emit('change', check, e);
|
||||
};
|
||||
|
|
|
@ -155,7 +155,7 @@ const Base = defineComponent<InternalBlockProps>({
|
|||
);
|
||||
|
||||
watchEffect(() => {
|
||||
if (!('content' in props)) {
|
||||
if (props.content === undefined) {
|
||||
warning(
|
||||
!props.editable,
|
||||
'Typography',
|
||||
|
@ -437,7 +437,7 @@ const Base = defineComponent<InternalBlockProps>({
|
|||
const { editing } = editable.value;
|
||||
const children =
|
||||
props.ellipsis || props.editable
|
||||
? 'content' in props
|
||||
? props.content !== undefined
|
||||
? props.content
|
||||
: slots.default?.()
|
||||
: slots.default
|
||||
|
|
Loading…
Reference in New Issue