2 回答

TA貢獻(xiàn)1906條經(jīng)驗(yàn) 獲得超10個(gè)贊
您確定到達(dá)了正確的終點(diǎn)嗎?
請(qǐng)參閱那個(gè)小示例(您可以嘗試在您的主機(jī)上進(jìn)行檢查)
$ tree
.
├── main.go
└── wwwroot
└── test.js
1 directory, 2 files
$ cat main.go
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
mux := mux.NewRouter()
mux.PathPrefix("/").Handler(http.FileServer(http.Dir("./wwwroot")))
http.ListenAndServe(":8080", mux)
}
$ cat wwwroot/test.js
$ go run main.go &
[1] 11841
$ curl -v http://localhost:8080/test.js
* Trying ::1:8080...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /test.js HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Type: application/javascript
< Last-Modified: Thu, 26 Sep 2019 12:12:15 GMT
< Date: Thu, 26 Sep 2019 12:15:36 GMT
<
* Connection #0 to host localhost left intact

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊
在我的項(xiàng)目中,我遇到了同樣的問(wèn)題。以下是我的解決方案:在tsconfig.json
文件中,make"target": "es5"
- 2 回答
- 0 關(guān)注
- 168 瀏覽
添加回答
舉報(bào)