这只是一个答案,因为我自己找不到答案,因此将其写给社区。有些人也注释掉了要玩的代码。
答案 0 :(得分:1)
<div id="map"> </div>
<script type="text/javascript">
function getMapHeight() {
return (window.innerHeight - 90);
}
$(function () {
let options = {
autoResize: true,
// width: '100%',
height: getMapHeight() + "px",
};
let network = new vis.Network($("#map"), data, options);
$(window).on('resize', function(){
network.setOptions({
// width: (window.innerWidth - 100) + "px",
height: getMapHeight() + "px",
});
});
});
</script>