<script src="https://js.sample.js/fetchsample" data-cb-site="your-site"
data-cb-fbq-enabled="true">
</script>
I have this script. in nuxt js we have this kind of structure
script: [
{src: "https://js.sample.js/fetchsample" , data-cb-site="your site", data-cb-fbq-enabled="true" }
]
But I am getting an error on adding that data-cb-ste and data-cb-fbq-enabled data attribute . Error:
SyntaxError: Unexpected token -
at new Script (vm.js:86:7)
at Generator.next (<anonymous>)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
Please help me.
Thanks in advance.
There is a hint in the SyntaxError you are getting:
SyntaxError: Unexpected token -
The dash -
is not allowed in property names outside of quotes.
So you need to change data-cb-site
to "data-cb-site"
where you define it in the object literal.
And when you access fields with a dash -
in the name, you must use square-bracket notation, eg object["data-cb-site"]
not object.data-cb-site
.
script: [
{
src: "https://js.sample.js/fetchsample",
"data-cb-site": "your site",
"data-cb-fbq-enabled": "true"
}
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.