Uncaught TypeError: TableInit is not a constructor

我最近在做东西的时候,用到了Bootstrap的表格,我复制了一份代码使用,结果运行报错

Uncaught TypeError: TableInit is not a constructor

我点进去一看,定位如下

var oTable = new TableInit();

其实这种错误,没办法调试,但是错误一般都是你少写了) } 或者写错了位置

就比如我这次,就是写错了位置

<script type="text/javascript">
        $(function() {
            //1.初始化Table
            var oTable = new TableInit();
            oTable.Init();
            //2.初始化Button的点击事件
            var oButtonInit = new ButtonInit();
            oButtonInit.Init();
        })

        var TableInit = function() {
            var oTableInit = new Object();
            //初始化Table
            oTableInit.Init = function() {

应该把TableInit方法放到Jquery的函数之外

原文地址:https://www.cnblogs.com/yunquan/p/11003317.html