第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法使用 dart 和 angular2 客戶端運(yùn)行 GolLang 后端

無(wú)法使用 dart 和 angular2 客戶端運(yùn)行 GolLang 后端

慕田峪9158850 2021-12-20 15:49:58
我使用本教程使用 GoLang、Angular2 和 Dart 制作 Web 應(yīng)用程序,但是當(dāng)我通過(guò)控制臺(tái)命令“backend”啟動(dòng)后端,并在瀏覽器中路由到“l(fā)ocalhost:8080/”時(shí),它必須從 Dart 的類“Hello”中調(diào)用方法,但是它沒(méi)有調(diào)用,我收到 404 錯(cuò)誤。我從教程中得到的所有代碼都沒(méi)有改變?nèi)魏螙|西。而且我找不到任何其他教程。你能解釋一下我做錯(cuò)了什么嗎?高朗代碼:func main() {   http.Handle("/", http.FileServer(http.Dir("./app/web/")))   fmt.Println("Text")   http.HandleFunc("/api/hello", helloWorld)   http.ListenAndServe(":8080", nil)}func helloWorld(w http.ResponseWriter, r *http.Request) {   data := struct {       Message string   }{       "Hello, World",   }   if err := json.NewEncoder(w).Encode(data); err != nil {       log.Println(err)   }}和角度飛鏢代碼:class AppComponent {   Hello hello = new Hello();}class Hello{  String message;  Hello(){    HttpRequest.getString('/api/hello')        .then((String content) {          Map parsedMap = JSON.decode(content);          message = parsedMap["Message"];        })        .catchError((Error error) {          print(error.toString());        });  }}我使用本教程使用 GoLang、Angular2 和 Dart 制作 Web 應(yīng)用程序,但是當(dāng)我通過(guò)控制臺(tái)命令“backend”啟動(dòng)后端,并在瀏覽器中路由到“l(fā)ocalhost:8080/”時(shí),它必須從 Dart 的類“Hello”中調(diào)用方法,但是它沒(méi)有調(diào)用,我收到 404 錯(cuò)誤。我從教程中得到的所有代碼都沒(méi)有改變?nèi)魏螙|西。而且我找不到任何其他教程。你能解釋一下我做錯(cuò)了什么嗎?高朗代碼:func main() {    http.Handle("/", http.FileServer(http.Dir("./app/web/")))    fmt.Println("Text")    http.HandleFunc("/api/hello", helloWorld)    http.ListenAndServe(":8080", nil)}func helloWorld(w http.ResponseWriter, r *http.Request) {    data := struct {        Message string    }{        "Hello, World",    }    if err := json.NewEncoder(w).Encode(data); err != nil {        log.Println(err)    }}和角度飛鏢代碼:class AppComponent {    Hello hello = new Hello();}class Hello{   String message;   Hello(){     HttpRequest.getString('/api/hello')         .then((String content) {          Map parsedMap = JSON.decode(content);           message = parsedMap["Message"];         })         .catchError((Error error) {          print(error.toString());         });   }}和項(xiàng)目結(jié)構(gòu):
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

教程已經(jīng)很老了。您需要切換到HashLocationStrategy(據(jù)我所知,這是當(dāng)時(shí)的默認(rèn)設(shè)置)。


見(jiàn)https://angular.io/docs/ts/latest/api/router/HashLocationStrategy-class.html


改變


bootstrap(AppComponent);


bootstrap(AppComponent, [

  ROUTER_PROVIDERS,

  provide(LocationStrategy, {useClass: HashLocationStrategy})

]);

您還需要添加一些額外的導(dǎo)入


import 'package:angular2/router.dart'

    show

        HashLocationStrategy,

        LocationStrategy,

        ROUTER_PROVIDERS;


查看完整回答
反對(duì) 回復(fù) 2021-12-20
  • 1 回答
  • 0 關(guān)注
  • 208 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)