-1
這裏出了什麼問題?我100%確定我正在發送一個HTTP POST請求,但不知何故OR操作符不能按我所期望的那樣工作。在第一個例子中,服務器返回405,在第二個例子中代碼繼續執行。||操作員不按預期方式工作
不工作:
if req.Method != http.MethodPost || req.Method != http.MethodDelete {
http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}
工作:
if req.Method != http.MethodPost {
http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}
看來你需要使用「&&」 - 你的病情始終爲TRUE – VladimirM
@ tom12e - CONSOLE.LOG您的REG對象,看看Method屬性是什麼 – Phil