我目前正在Next.js中构建一个应用程序,我想禁用打开devtools。我在npm上找到了一个很好的包-禁用-开发工具- https://www.npmjs.com/package/disable-devtool,但问题是,nextjs一直向我抛出ReferenceError: navigator is not defined。我试图调查node_modules,但没有找到任何解决方案,请提供任何帮助?
谢谢你,❤️
发布于 2022-06-08 21:02:51
试试这个:
if (
typeof window !== "undefined" &&
typeof window.navigator !== "undefined" &&
typeof navigator !== "undefined" &&
navigator.userAgent
) {
const disableDevtool = require("disable-devtool");
disableDevtool();
}https://stackoverflow.com/questions/72494091
复制相似问题