在我的 nuxt.js 应用程序中,我有一个脚本导入仅与浏览器上下文兼容的 NPM 包(它引用 document、location、window 等)
有没有办法将其从 SSR 中排除?
import thing from "@vendor/thing"; // causes `document not defined` error
export default showThing(){
if (process.client) {
thing();
}
}
我可以使用 process.client 的方法,但该文件仍然导入到我的组件中。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号