Html 在屏幕上显示图像

Html 在屏幕上显示图像,html,angular,ionic-framework,Html,Angular,Ionic Framework,首先,当我提出请求时会出现这个错误 SyntaxError: Unexpected token � in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.onLoad (http://localhost:8100/vendor.js:9848:51) at ZoneDelegate.invokeTask (http://localhost:8100/polyfills.js:3722:31) at Ob

首先,当我提出请求时会出现这个错误

SyntaxError: Unexpected token � in JSON at position 0
at JSON.parse (<anonymous>)
at XMLHttpRequest.onLoad (http://localhost:8100/vendor.js:9848:51)
at ZoneDelegate.invokeTask (http://localhost:8100/polyfills.js:3722:31)
at Object.onInvokeTask (http://localhost:8100/vendor.js:71849:33)
at ZoneDelegate.invokeTask (http://localhost:8100/polyfills.js:3721:60)
at Zone.runTask (http://localhost:8100/polyfills.js:3499:47)
at ZoneTask.invokeTask [as invoke] (http://localhost:8100/polyfills.js:3796:34)
at invokeTask (http://localhost:8100/polyfills.js:4934:14)
at XMLHttpRequest.globalZoneAwareCallback (http://localhost:8100/polyfills.js:4971:21)

接下来我要做的是在details.page.html中显示图像。我该怎么做呢?

我建议您使用get请求从api返回文件图像,并将url直接写入src标记中的img源。另一种方法是,在将源代码交给src tagI之前,您需要信任它,因为它从后端返回了一个映像。我如何在Ionic中显示它?只需将它放到image属性的src标记中,如本例所示
let head= new HttpHeaders;
    head.append('reid', id);
    head.append('responseType', 'image');

    this.http.get('http://127.0.0.1:8000/getimg', {headers: head}).subscribe(result => {
        this.data = result;
        console.log("was : " ,id);
        console.log(this.data);
        }, error => console.error(error));