问题描述
当我使用nuxt
开发我的项目时,我发现了一些问题.
When I use nuxt
to develop my project, I find some problems.
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
我可以删除它或使用js文件替换它吗?
can I remove it or use js file to replace it?
推荐答案
我找到了一个比较完美的解决方案.我将在这里与您分享.你也可以看看我用NUXT开发的网站Sample Website
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
关键是hook
函数vue-renderer:ssr:context
,可以设置context.nuxt = null
去掉任何window._NUXT_
中的数据.
The key is the hook
function vue-renderer:ssr:context
, you can set the context.nuxt = null
to remove any data in window._NUXT_
.
但效果不佳,必须将serverRender
和routePath
添加到window.nuxt
But it is not work well, you have to add serverRender
and routePath
to window.nuxt
// nuxt.config.js
{
...,
hooks: {
'vue-renderer:ssr:context'(context) {
const routePath = JSON.stringify(context.nuxt.routePath);
context.nuxt = {serverRendered: true, routePath};
}
}
}
您可以在我的网站
这篇关于如何在nuxt项目中删除window._nuxt_,它对我来说太大了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!