style: update pageheader

feat-css-var
tangjinzhou 2022-03-05 14:51:16 +08:00
parent d38ecce22c
commit e610e8a861
3 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,12 @@
import { onBeforeUnmount, ref } from 'vue';
const useDestroyed = () => {
const mounted = ref(true);
onBeforeUnmount(() => {
mounted.value = false;
});
return mounted;
};
export default useDestroyed;

View File

@ -9,7 +9,7 @@ title:
## zh-CN ## zh-CN
在不同大小的屏幕下应该有不同的表现 在不同大小的屏幕下应该有不同的表现
## en-US ## en-US

View File

@ -12,6 +12,7 @@ import { withInstall } from '../_util/type';
import useConfigInject from '../_util/hooks/useConfigInject'; import useConfigInject from '../_util/hooks/useConfigInject';
import classNames from '../_util/classNames'; import classNames from '../_util/classNames';
import ResizeObserver from '../vc-resize-observer'; import ResizeObserver from '../vc-resize-observer';
import useDestroyed from '../_util/hooks/useDestroyed';
export const pageHeaderProps = { export const pageHeaderProps = {
backIcon: PropTypes.any, backIcon: PropTypes.any,
@ -37,8 +38,11 @@ const PageHeader = defineComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const { prefixCls, direction, pageHeader } = useConfigInject('page-header', props); const { prefixCls, direction, pageHeader } = useConfigInject('page-header', props);
const compact = ref(false); const compact = ref(false);
const isDestroyed = useDestroyed();
const onResize = ({ width }: { width: number }) => { const onResize = ({ width }: { width: number }) => {
compact.value = width < 768; if (!isDestroyed.value) {
compact.value = width < 768;
}
}; };
const ghost = computed(() => props.ghost ?? pageHeader.value?.ghost ?? true); const ghost = computed(() => props.ghost ?? pageHeader.value?.ghost ?? true);