1
我正在嘗試構建一個應用程序,該應用程序使用Google圖表api繪製折線圖。 我已經設置了一件事情,就是窗口中的「調整大小」事件的事件監聽器。這會觸發折線圖重新繪製尺寸設置爲'window.innerWidth'和'window.innerHeight'以適應新的窗口尺寸。電子「窗口」未定義
這一切工作得很好,如果我使用npm start運行應用程序。問題是當我使用電子包裝程序構建應用程序時。運行它生成的exe拋出這樣的:
這裏是我的HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>AP Test Viewer</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body ng-app="ApApp" ng-controller="MainController">
<a ui-sref="single">Single</a>
<a ui-sref="multi">Multi</a>
<ui-view></ui-view>
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js');
require('./js/loader.js'); //google charts loader.js
require('./js/app.js');
</script>
</html>
和我的應用程序,在這裏我用窗口的相關部分在這裏:
app.fun.drawGraph = function(){
if(app.data.graphConfig){
app.data.graphConfig.options.width = window.innerWidth * 0.97;
app.data.graphConfig.options.height = window.innerHeight * 0.90;
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(app.data.graphConfig.data, app.data.graphConfig.options);
// chart.draw($scope.graphData, google.charts.Line.convertOptions(options));
}
}
window.addEventListener('resize', function(e){
if(app.data.graphConfig){
app.fun.drawGraph();
}
})
至於我知道,這應該只是'窗口',可以通過網頁上的JavaScript訪問。
你解決了這個問題嗎?我面臨同樣的問題。 – ThunderWiring