https://codesandbox.io/s/7432lomjpx
nuxt.config.js
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
script: [
{ innerHTML: 'document.documentElement.classList.add("theme-" + (localStorage.theme || "day"))' },
],
},
....
}
' and " are displayed correctly
<script data-n-head="true" >document.documentElement.classList.add("theme-" + (localStorage.theme || "day"))</script>
This is an intended feature of vue-meta. You can disable it as well if you want. More information in the vue-meta docs. In-production example here
@xuexb When you want to inject script into template by parameter head.script in nuxt.config.js, and add __dangerouslyDisableSanitizers: ['script'], can solve your problem. But, I think customizing your template is a better method. After you do this, you can write any script you want in your HTML document.
Relative issue https://github.com/nuxt/nuxt.js/issues/2230
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.