【问题标题】:JavaScript error using bootstrap-table使用引导表的 JavaScript 错误
【发布时间】:2017-06-15 13:52:49
【问题描述】:

我正在尝试将引导表与 MVC 一起使用。我在脚本和内容中有以下文件:

bootstrap-table.js
bootstrap-table.min.js
bootstrap-table-locale-all.js
bootstrap-table-locale-all.min.js

bootstrap-table.css
bootstrap-table.min.css

然后我在 bundleconfig.cs 文件中使用以下内容:

        bundles.Add(new ScriptBundle("~/bundles/bootstraptable").Include(
                  "~/Scripts/bootstrap-table*"));

        bundles.Add(new StyleBundle("~/Content/bootstraptable").Include(
                  "~/Content/bootstrap-table*"));

这些在“_Layout.cshtml”文件中:

    @Styles.Render("~/Content/bootstraptable")
    @Scripts.Render("~/bundles/bootstraptable")

我还包含 jQuery 和 Bootstrap(并且可以正常工作),所以我认为这不是依赖问题。

当我运行项目时(甚至在我尝试对表格做任何事情之前),我得到:

Unable to get property 'locales' of undefined or null reference

没有用于此的 NuGet 包,所以我不得不手动添加文件,所以也许我错过了一些东西。但根据网站 (http://bootstrap-table.wenzhixin.net.cn/getting-started/) 看来,我有我需要的东西。

有人遇到过这个问题或知道我做错了什么吗?

谢谢。

【问题讨论】:

    标签: javascript asp.net-mvc twitter-bootstrap bundling-and-minification bootstrap-table


    【解决方案1】:

    显然,捆绑包中的文件列表对此很重要。当我将它与通配符捆绑在一起时,它不起作用。当我把它切换到

            bundles.Add(new ScriptBundle("~/bundles/bootstraptable").Include(
                      "~/Scripts/libs/bootstrap-table.js",
                      "~/Scripts/libs/bootstrap-table-en-US.js"));
    

    明确地将 2 个必要的文件放入包中(我将“所有”语言环境替换为我需要的文件),然后它就起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 2019-07-10
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多