Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

地图的高度如何设置为容器的高度 #70

Closed
redwolf1996 opened this issue Jun 12, 2024 · 6 comments
Closed

地图的高度如何设置为容器的高度 #70

redwolf1996 opened this issue Jun 12, 2024 · 6 comments

Comments

@redwolf1996
Copy link

请问组件的height应该如何设置,才能自适应父容器的高度,设置100%无效
image

@sisabyss
Copy link

sisabyss commented Jul 1, 2024

同求,有解决方案了吗

@yue1123
Copy link
Owner

yue1123 commented Jul 6, 2024

再写一个style="height:100%"试试

@sisabyss
Copy link

sisabyss commented Jul 6, 2024

再写一个style="height:100%"试试

疑似不支持百分比,我是这样解决的:

const screenHeight = ref(window.innerHeight);

const updateHeight = () => {
  screenHeight.value = window.innerHeight;
};
<BMap :height="screenHeight"/>

@yue1123
Copy link
Owner

yue1123 commented Jul 7, 2024

不支持百分比是因为渲染容器外层还有一个div(也就是map组件根节点),这个div高度没有继承,所以再加一个style="height:100%"就可以生效了,这个下个小版本会优化下

yue1123 added a commit that referenced this issue Jul 7, 2024
close 地图的高度如何设置为容器的高度 #70
yue1123 added a commit that referenced this issue Jul 7, 2024
@yue1123 yue1123 closed this as completed in 5297a8e Jul 7, 2024
yue1123 added a commit that referenced this issue Jul 7, 2024
@redwolf1996
Copy link
Author

同求,有解决方案了吗

刚看到,发现作者已经解决了 :)

@redwolf1996
Copy link
Author

不支持百分比是因为渲染容器外层还有一个div(也就是map组件根节点),这个div高度没有继承,所以再加一个style="height:100%"就可以生效了,这个下个小版本会优化下

谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants