ionic2:ios模拟器错误:状态响应:URL为0:null

时间:2018-01-01 11:15:09

标签: ionic-framework ionic2

我使用ionic2:我的应用程序使用Web服务API并且它在浏览器中正常工作,因为我在浏览器中启用了Private Sub CommandButton1_Click() '//this macro checks whether two sheet's data is correspondent. Dim i1 As Long Dim i2 As Long Dim text1 As String Dim text2 As String text1 = UserForm2.TextBox1.Value text2 = UserForm2.TextBox2.Value Dim testSheet1 As Worksheet Dim testSheet2 As Worksheet testSheet1 = ThisWorkbook.Worksheets(text1) testValue2 = ThisWorkbook.Worksheets(text2) For i2 = 1 To 31 For i1 = 1 To 27 If testSheet1.Cells(i1, i2).Value <> testSheet2.Cells(i1, i2).Value Then MsgBox "Value of " & i1 & "rows " & i2 & "column : " & Chr(13) & Chr(10) _ & text1 & " sheets : " & testSheet1.Cells(i1, i2).Value & Chr(13) & Chr(10) _ & text2 & " sheets : : " & testSheet2.Cells(i1, i2).Value End If Next i1 Next i2 MsgBox "End" End Sub 但是我将它运行到ios模拟器我有这样的错误:{{1在我所有的api服务方法中,我都附加了这样的标题:

cors origin plugin

我尝试发送这样的标题:

Response with status: 0 for URL: null
我设置的addPost(token, image, description) { var headers = new Headers(); headers.append('Content-Type', 'applocation/json'); headers.append('Access-Control-Allow-Origin', '*'); let postObject = { "token": token, "image": image, "description": description, } console.log("from service "+ postObject.description); console.log("from service "+ postObject.image); return this.http.post(this.addPostUrl,postObject,{headers:headers}) .map((response: Response) => response.json()) } 文件中的

let headers = new Headers( {
        'Access-Control-Allow-Origin' : '*',
        'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
        'Content-Type': 'application/json; charset=UTF-8',
        'Accept': 'application/json',
        'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
    });

但运行到ios模拟器时出现同样的错误,我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

我在Windows 10上发现了我的问题并希望分享。我希望它能提供一些见解。 Windows 8.1 / 10上的UWP拒绝环回。它必须设置为免除。

Can't see localhost from UWP app