亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

報錯:Uncaught TypeError: LightBox is not a constructor

大家幫我看看代碼,代碼跟視頻上的一樣啊,為什么不能alert 1出來。

報錯:Uncaught TypeError: LightBox is not a constructor ?


js:

;(function($) {

var LightBox = function() {

var self = this;

//創建遮罩和彈出框

this.popupMask = $("<div id='G-lightbox-mask'></div>")

this.popupWin = $("<div id='G-lightbox-popup'></div>")

//保存body

this.bodyNode = $(document.body);

//渲染剩余的DOM插入到body;

this.renderDOM();

};

LightBox.prototype = {

renderDOM: function() {

alert("1");

}

};

window["LightBox"] = LightBox;?

})(jQuery);


html頁面

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title></title>

<script src="js/jquery-2.2.1.min.js"></script>

<script src="js/LightBox.js"></script>

</head>

<body> ?


<script>

$(function(){

var LightBox = new LightBox();

})

</script>

</body>

</html>


正在回答

2 回答

var LightBox = new LightBox(); 加粗的要小寫,別沖突,或用其他的名字!!

0 回復 有任何疑惑可以回復我~

LightBox 不是構造函數

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

報錯:Uncaught TypeError: LightBox is not a constructor

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號