我试图加载包含使用jquery $.getScript
通过webpack编译的代码的bundle.js。但是,它显示空白页面。但是当我尝试使用常规脚本标签时,它就可以了。使用$.getScript
的原因是因为我有两个环境,我只想在生产环境中加载其他脚本。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Single Page Program Demo</title>
<script src="../Programs/2999/js/jquery-2.2.3.min.js"></script>
<script>
/* Environment - (options: development / production) */
var env = 'development';
/* Load all scripts related to pi shell integration in sequence */
$.getMultiScripts = function(arr, path) {
var _arr = $.map(arr, function(scr) {
return $.getScript( (path||"") + scr );
});
_arr.push($.Deferred(function( deferred ){
$( deferred.resolve );
}));
return $.when.apply($, _arr);
}
var script_arr;
if (env == 'production'){
script_arr = [
'jquery-2.2.3.min.js',
'json2.js',
'jquery.validate.min.js',
'PIH.PIPlatform.ClientSideStorage.js',
'jquery.idletimer.js',
'jquery.idletimeout.js',
'DataTransfer.js',
'pi_utility.js',
'pi_data.js',
'bundle.js'
];
}
else {
script_arr = [
'bundle.js'
];
}
$.getMultiScripts(script_arr, '../Programs/2999/js/').done();
</script>
</head>
<body>
<div id="app"></div>
<!-- This works -->
<!-- <script src="../Programs/2999/js/bundle.js"></script> -->
</body>
</html>