我需要在 iframe 元素的 src 属性中插入一个 API 密钥和一个位置字符串。
这是我的 iframe 在 atm 中的样子:
<iframe class="center-block" src="https://www.google.com/maps/embed/v1/[email protected]('aPIKey')&[email protected]('lokation')" width="95%" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>
但是当我转到页面时,出现此错误:
Too many characters in character literal
我尝试使用 "" 代替 razor 属性,但这会破坏文档其余部分的格式。
我真的很困惑在 HTML 属性中使用 Razor 语法的正确方法是什么。
@Umbraco.Field('lokation') @Umbraco.Field('aPIKey')
应该
@Umbraco.Field("lokation") @Umbraco.Field("aPIKey")
该'
报价是用于字符文字中c#
现在,因为您"
在 razor中使用引号,所以您需要将 html 引号更改为'
.
<iframe class="center-block" src='https://www.google.com/maps/embed/v1/[email protected]("aPIKey")&[email protected]("lokation")' width="95%" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句