|
@@ -1,4 +1,4 @@
|
|
|
-import { defineComponent, onMounted, ref } from 'vue'
|
|
|
+import { defineComponent, nextTick, onMounted, ref } from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
|
|
|
import IconMall from '../../images/icon-mall.png'
|
|
@@ -12,7 +12,7 @@ import ColSticky from '@/components/col-sticky'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'TheHomeHeader',
|
|
|
- emits: ['cart', 'more', 'search'],
|
|
|
+ emits: ['cart', 'more', 'search', 'headerDom'],
|
|
|
setup(props, { emit, expose }) {
|
|
|
const navBarHeight = ref(sessionStorage.getItem('navHeight'))
|
|
|
const init = () => {
|
|
@@ -30,18 +30,20 @@ export default defineComponent({
|
|
|
})
|
|
|
}
|
|
|
init()
|
|
|
- const homeHeader = ref<any>(null)
|
|
|
+ const homeHeaderDom = ref(null)
|
|
|
|
|
|
- const getHeadeHeight = () => {
|
|
|
- const { height } = useRect(homeHeader.value)
|
|
|
- return height
|
|
|
- }
|
|
|
- expose({
|
|
|
- getHeadeHeight
|
|
|
+ onMounted(() => {
|
|
|
+ nextTick(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ const { height } = useRect(homeHeaderDom as any)
|
|
|
+ emit('headerDom', height)
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
})
|
|
|
+
|
|
|
return () => (
|
|
|
<ColSticky position="top">
|
|
|
- <div class={styles.theHomeHeader} ref={homeHeader}>
|
|
|
+ <div class={styles.theHomeHeader} ref={homeHeaderDom}>
|
|
|
<div
|
|
|
style={{ height: navBarHeight.value + 'px', background: '#fff' }}
|
|
|
></div>
|