嗨,我正在嘗試將一些字符串參數(shù)傳遞到我的網(wǎng)址,以便我可以從 API 獲取信息。這工作正常,當(dāng)在警報(bào)中顯示時(shí),會(huì)完全按照應(yīng)有的方式顯示 url(不包含 [object, object])。var startDate = "2020-09-20" ;var endDate = "2020-11-20";var apiUrl = 'https://thisismyurls7F174D955BF8&dateFrom='+{startDate}+' &dateTo='+{endDate}+'T18%3A56%3A58.930Z&showAllFutureItinerary=true'但是,當(dāng)我這樣做時(shí)。CustomSearch(startDate: string,endDate: string) { var Url = 'https://localhost:44381/api/internal/itinerary/all?userId=996D7BD5-C625-5C7E-6A02- 7F174D955BF8&dateFrom='+{startDate}+'T18%3A56%3A58.930Z&dateTo='+ {endDate}+'T18%3A56%3A58.930Z&showAllFutureItinerary=true'.toString();}它無法訪問 API,并且當(dāng) console.logged/alerted 顯示變量都是 [object object] 時(shí)。這些是從另一個(gè)組件的 onsubmit 函數(shù)傳遞的,如下所示。model = { startDate: String, endDate: String, search: String}constructor(private itineraryService: ItineraryService) {}onSubmit() { // var a = JSON.stringify(this.model) if (this.model.endDate != undefined && this.model.startDate != undefined) { this.items = this.itineraryService.CustomSearch(this.model.startDate.toString(), this.model.endDate.toString()) }我基本上只需要將它們都作為字符串而不是將它們顯示為 [object object]
通過 URL 傳遞參數(shù)將其顯示為 [object object] 而不是字符串(打字稿)
幕布斯7119047
2023-06-09 15:32:12