我正在使用Next.js构建一个网站,尝试实现外部的.js文件(Bootstrap.min.js和Popper.min.js),但是它没有显示出来。我不确定问题出在哪里!
I implemented it like this:
import Head from 'next/head';
//partials
import Nav from './nav'
const Layout = (props) => (
<div>
<Head>
<title>Site</title>
{/* Meta tags */}
<meta charset="utf-8"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"></meta>
{/* Standard page css */}
<link rel="stylesheet" type="text/css" href="/static/css/page.css"/>
{/* Bootstrap CSS */}
<link rel="stylesheet" href="/static/includes/bootstrap.min.css"/>
{/* jQuery first, then Popper.js, then Bootstrap JS */}
<script src="/static/includes/popper.min.js"></script>
<script type="text/javascript" src="/static/includes/bootstrap.min.js"></script>
</Head>
<Nav/>
{props.children}
</div>
);
export default Layout;
看起来对我来说很好?我错过了什么,它没有像应该的那样显示!
当我尝试在页面内部运行脚本时,它只显示了“Hello JavaScript”,但仅持续了很短的时间,然后就消失了?
<p id="demo"></p>
<script>document.getElementById("demo").innerHTML = "Hello JavaScript";</script>
我该如何修复它?
请帮忙!
我正在使用: "next": "^8.0.3", "react": "^16.8.4", "react-dom": "^16.8.4"