我在项目中使用Bootstrap 4和Jquery-3.3.1。 我使用js如下:
<script src="@Url.Content("~/Scripts/jquery-3.3.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/umd/popper.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap.min.js")" type="text/javascript"></script>
页面加载时,出现以下错误:
SyntaxError: export declarations may only appear at top level of a module ----- popper.min.js:4:19633
TypeError: Bootstrap's tooltips require Popper.js (https://popper.js.org/) ------ bootstrap.min.js:6:34702
这些警告还会给出:
Source map error: request failed with status 404
Resource URL: http://sitename.com/Content/bootstrap.css
Source Map URL: bootstrap.css.map
Source map error: request failed with status 404
Resource URL: http://sitename.com/Scripts/bootstrap.min.js
Source Map URL: bootstrap.min.js.map
请指导我
答案 0 :(得分:5)
我有同样的问题。我只是在Bootstrap.min.js之前导入Popper.js。现在可以了。
答案 1 :(得分:1)
在本地(离线)使用popper下载de umd版本并将src设置为path https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js
<script src="path/popper.min.js"></script>
答案 2 :(得分:0)
您似乎正在尝试对这些脚本使用本地导入,这可能只是意味着您的popper.min.js文件不在正确的目录中。如果不是这种情况,那么我将对这些脚本使用CDN(内容交付网络)导入,因为使用起来要简单得多。例如:
if (getFragmentManager().findFragmentByTag("...the tag") == null) {
fragment.show(getFragmentManager(), "...the tag");
}