NUXT将RAW(静态)HTML添加到组件
在例如
<!doctype html>
<html lang="en" data-n-head="...">
<head>...nuxt generated head...</head>
<script>
// this tag needs to exist as html when building with 'yarn generate'
// @@config@@ is a macro
let config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
</script>
<body>
... nuxt generated body ...
</body>
本质上,当我运行命令YARN生成
时,我想要一个特定的页面(pages/login/index.html
)以具有此特定标签的存在,并且在期间不注射Vue的生命周期。还有其他解决方案,例如让脚本自动后处理静态页面输出,但是我希望有一种方法可以在没有这种并发症的情况下完成此操作。
我的nuxt版本是2.15.8
In examples like this we have the v-html directive to dynamically render the raw html into the dom. I am in need of a way to insert a raw script before the entire lifecycle begins its magic. This is because I am working with a macro (auth0).
<!doctype html>
<html lang="en" data-n-head="...">
<head>...nuxt generated head...</head>
<script>
// this tag needs to exist as html when building with 'yarn generate'
// @@config@@ is a macro
let config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
</script>
<body>
... nuxt generated body ...
</body>
In essence, when I run the command yarn generate
I would like a specific page (pages/login/index.html
) to have this specific tag to exist and not injected during vue's lifecycle. There are alternate solutions like having scripts automatically postprocessing the static page output, but I'm hoping that there is a way to accomplish this without such complications.
My nuxt version is 2.15.8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论