【Nuxt.js】metaタグにhttp-equivを設定する
Nuxtを使ってmetaタグにhttp-equivを設定する時、ハマったので備忘録
nuxt.config.jsに
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ http-equiv: 'X-UA-Compatible', content: 'IE=edge' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
{ hid: 'description', name: 'description', content: 'default-description' }
]}
のように設定した時、”SyntaxError: Unexpected token -” エラーが出て、http-equivが設定できませんでした
下記のようにhttp-equivを’’で囲むことで解決。
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ ’http-equiv': 'X-UA-Compatible', content: 'IE=edge' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
{ hid: 'description', name: 'description', content: 'default-description' }
]}
下記参考にした記事
1. 同じ症状のIssue
2. http-equivについて(http-equivは、日本語の文字化けなどを防ぐために設定します。)
3.Nustでmetaタグを設定する方法
以上ですーーー!!
おやすみなさいぃぃ