【发布时间】:2019-10-23 23:21:44
【问题描述】:
我试图在 HTML 浏览器中显示下面的字符串,但是当浏览器在字符串中遇到像“”这样的自定义标签时,它只是跳过了那个。
我尝试了 encodeURIComponent(),后来又尝试在我的 HTML 模板中 decodeURIComponent,但没有成功。
我什至尝试通过创建如下所示的 PIPE 来清理 HTML,但没有成功。
transform(v: string): SafeHtml {
return this._sanitizer.bypassSecurityTrustHtml(v);
}
不知何故,浏览器正在跳过字符串中的元素。
后面是字符串
“The endpoint is browser-based, rather than RESTful. Therefore it could
result in the following different scenarios,↵1. SUCCESS
(response_type=code)↵> redirect_uri?code=<authorization-code>&scope=
<resource-owner-approved-scopes>[&state=<state-provided-by-the-client>]."
【问题讨论】:
-
使用 ' ' 而不是 ' " '?也许这可以帮助你:developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
-
你想用这个字符串做什么?将其插入
innerHTML属性,也许? -
您的意思是将字符串放在反引号而不是双引号之间。我正在从服务器获取此字符串。
-
@jacob 是的,我正在使用 innerHTML 将其插入到 div 中。
-
您的报价不匹配。
标签: javascript html typescript decode encode