1
我已經在我的網頁的部分如下:JavaScript的訪問成員
<head>
<link rel='stylesheet' href='style.css' />
<script language='javascript' src='scripts/jquery-1.7.1.min.js'></script>
<script language='javascript' src='scripts/NumberMaze.js'></script>
<script language='javascript' src='scripts/GameConfig.js'></script>
<script language='javascript' src='scripts/UIManager.js'></script>
<script>
$(document).ready(function() {
var game = new NumberMaze();
});
</script>
</head>
GameConfig.js包含:
(function(undefined) {
NumberMaze.GameConfig = function() {
return {
minCanvasWidth : 320,
minCanvasHeight : 240,
maxCanvasWidth : 640,
maxCanvasHeight : 480,
};
};
})();
NumberMaze.js包含:
(function($, undefined) {
NumberMaze = function() {
console.log(NumberMaze.GameConfig.minCanvasWidth);
console.log(NumberMaze.GameConfig);
};
})(jQuery);
對於NumberMaze.js中的日誌,我得到以下輸出。我如何訪問minCanvasWidth的值。我的代碼有什麼問題?
undefined
function() {
return {
minCanvasWidth : 320,
minCanvasHeight : 240,
maxCanvasWidth : 640,
maxCanvasHeight : 480,
};
}
aww .. GameConfig是一個函數。正確.. thx指出它:) – saiy2k