我试图获取 /page/_document.js 文件中的当前路径名。我正在使用一个类,我的目标是用该值创建一个条件。
这是我的代码(基本上是 NextJS 页面中的示例)
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Next.js 项目导入 Bootstrap。我的进口顺序是:
import 'jquery';
import 'bootstrap';
Run Code Online (Sandbox Code Playgroud)
我尝试了另一种语法...
require('jquery');
require('bootstrap');
Run Code Online (Sandbox Code Playgroud)
但结果是一样的...
类型错误:无法读取未定义的 jQueryDetection /node_modules/bootstrap/dist/js/bootstrap.js:243:26 的属性“jquery”
我颠倒了进口的位置,但不起作用......
我在 index.js 页面中,并且...我安装了两个软件包