我想知道如何将字符串插入javascript代码中,如下例所示:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Restaurant",
"name": "Dave's Steak House",
"address": {
"@type": "PostalAddress",
"streetAddress": "148 W 51st St",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10019",
"addressCountry": "US"
}
}
</script>
问题在于,当我尝试在js之间插入字符串时,它似乎被解释为带有%
,&20
等的HTML代码。我尝试使用?html
,{{1} },escape
,no escape
,?string
等。
那是字符串:
?js_string,
代码:
$ {}的myString