sách gpt4 ai đã đi

html - Hiển thị văn bản có thẻ html dưới dạng html

In lại 作者:行者123 更新时间:2023-11-28 00:45:18 25 4
mua khóa gpt4 Nike

我正在尝试将文本文件显示为 html。我正在使用 ionic 。我正在发送一个 html 格式的响应,但在一个文本文件中发送到配置文件页面。它在 .ts 页面的变量名中。

@Thành phần({
selector: 'page-profile',
templateUrl: 'profile.html',
})
export class ProfilePage{
name: any;

constructor(public navCtrl: NavController, public navParams: NavParams) {
this.name = navParams.get('name');

现在我尝试使用 html 格式显示它

{{name}}

但我得到的是文本格式,而不是 html。如何以html格式显示?

1 Câu trả lời

您需要使用 DomSanitizer绕过您提供的 html(bypassSecurityTrustHtml)。

constructor(public navCtrl: NavController,
public navParams: NavParams,
private sanitizer: DomSanitizer) {

this.name = sanitizer.bypassSecurityTrustHtml(navParams.get('name'));

}

在这里阅读更多:https://angular.io/guide/security#bypass-security-apis

关于html - 将带有 html 标签的文本显示为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50964849/

25 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com