<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="jquery-1.12.4.js"></script> <script src="2.js"></script> <script src="1.js"></script> </head> <body> <audio src=""></audio> </body> </html>
闭包 即2.js 创建一个函数的原型对象init函数
(function (window) { function Player($audio) { return new Player.prototype.init($audio); } window.Player = Player; })(window);
调用 即 1.js 闭包创建 对象
$(function () { var $audio = $("audio"); var Player = new Player($audio); })
为何创建的 player 报错:Uncaught TypeError: Player is not a constructor
番茄乌梅
相关分类