refactor: alert by ts
parent
642ed2fcce
commit
043f401636
|
@ -1,4 +1,4 @@
|
||||||
import { Transition, inject, cloneVNode } from 'vue';
|
import { Transition, inject, cloneVNode, defineComponent, App } from 'vue';
|
||||||
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
|
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
|
||||||
import CheckCircleOutlined from '@ant-design/icons-vue/CheckCircleOutlined';
|
import CheckCircleOutlined from '@ant-design/icons-vue/CheckCircleOutlined';
|
||||||
import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOutlined';
|
import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOutlined';
|
||||||
|
@ -56,10 +56,11 @@ export const AlertProps = {
|
||||||
onClose: PropTypes.func,
|
onClose: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Alert = {
|
const Alert = defineComponent({
|
||||||
name: 'AAlert',
|
name: 'AAlert',
|
||||||
props: AlertProps,
|
props: AlertProps,
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
|
emits: ['close'],
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
configProvider: inject('configProvider', defaultConfigProvider),
|
configProvider: inject('configProvider', defaultConfigProvider),
|
||||||
|
@ -72,7 +73,7 @@ const Alert = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClose(e) {
|
handleClose(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const dom = findDOMNode(this);
|
const dom = findDOMNode(this);
|
||||||
dom.style.height = `${dom.offsetHeight}px`;
|
dom.style.height = `${dom.offsetHeight}px`;
|
||||||
|
@ -156,10 +157,10 @@ const Alert = {
|
||||||
</Transition>
|
</Transition>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Alert.install = function(app) {
|
Alert.install = function(app: App) {
|
||||||
app.component(Alert.name, Alert);
|
app.component(Alert.name, Alert);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue