[英]How to remove window._nuxt_ in nuxt project, it is too large for me
When I use nuxt
to develop my project, I find some problems.我在使用
nuxt
开发项目的时候,发现了一些问题。
window.__NUXT__=(function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,$,aa, ..... code was too larger
can I remove it or use js file to replace it?我可以删除它或使用 js 文件来替换它吗?
I have found a relatively perfect solution.我找到了一个相对完美的解决方案。 I will share it with you here.
我将在这里与您分享。 You can also take a look at the website I developed using NUXT Sample Website
你也可以看看我用NUXT Sample Website开发的网站
The key is the hook
function vue-renderer:ssr:context
, you can set the context.nuxt = null
to remove any data in window._NUXT_
.关键是
hook
函数vue-renderer:ssr:context
,你可以设置context.nuxt = null
来移除window._NUXT_
中的任何数据。
But it is not work well, you have to add serverRender
and routePath
to window.nuxt
但效果不佳,必须在
window.nuxt
添加serverRender
和routePath
// nuxt.config.js
{
...,
hooks: {
'vue-renderer:ssr:context'(context) {
const routePath = JSON.stringify(context.nuxt.routePath);
context.nuxt = {serverRendered: true, routePath};
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.