尝试从本地数据库将值作为 iframe url 传递,并且收到错误消息:资源 URL 上下文中使用的值不安全。我正在尝试显示一系列打印机 IP,这样我就可以通过网站检查它们的状态,有没有办法在没有 iframe 的情况下做到这一点?我会很高兴听到一些建议。
我是角度新手,非常欢迎您提供任何帮助,提前致谢。
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'app-value',
templateUrl: './value.component.html',
styleUrls: ['./value.component.css']
})
export class ValueComponent implements OnInit {
values: any;
constructor(private http: HttpClient, private sanitizer: DomSanitizer) { }
ngOnInit() {
this.getValues();
}
getValues() {
this.http.get('http://localhost:5000/api/values/').subscribe(response => {
this.values = response;
}, error => {
console.log(error);
})
}
}Run Code Online (Sandbox Code Playgroud)
<H2>Print Manager</H2>
<div id="outerdiv">
<iframe src="http://192.168.1.6/general/status.html" id="inneriframe" …Run Code Online (Sandbox Code Playgroud)