gpt4 book ai didi

javascript - 找不到名称 'SafeUrl'

转载 作者:行者123 更新时间:2023-11-28 13:13:44 25 4
gpt4 key购买 nike

我正在尝试从添加了bypassSecurityTrustUrl方法的控制台中删除不安全警告。但我收到错误

user.component.ts

import {Component,OnInit} from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { NavParams,Platform,ViewController } from 'ionic-angular';

@Component({
templateUrl:`<a [href]="sanitize('sms:'+user.mobile_no)" class="anchor-default">Text</a>`,
styles:[`
.anchor-black{color: #000; font-size: 2.4rem;}
.anchor-default {text-decoration: none;}
.custom-margin{margin-left:10px;}
.anchor-right{float:right;padding-top:2px;}
.text-content{text-overflow: ellipsis; vertical-align: middle; padding-top:12px;}
`]
})

export class User implements OnInit {

public user;

public bStandings:boolean = false;

constructor(
public navParams:NavParams,
public viewCtrl:ViewController,
public platform:Platform,
public domSanitizer:DomSanitizer
) {}

sanitize(url:string){
return this.sanitizeUrl(url);
}

private sanitizeUrl(url:string):SafeUrl {
this.bStandings = true;
return this.domSanitizer.bypassSecurityTrustUrl(url);
}

}

相关问题: Class has or is using name 'SafeUrl' from external module but cannot be named

任何人请帮助我提前致谢

最佳答案

只需导入 SafeUrl 即可:

import { DomSanitizer, SafeUrl } from '@angular/platform-browser';

关于javascript - 找不到名称 'SafeUrl',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40467870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com