簡體   English   中英

雖然我正確創建了路線但是當我嘗試顯示頁面時它給了我一個找不到錯誤頁面

[英]Although I created the route correctly But when I try to show the page It gives me an error page not found

這是我在 MemberController 中的 function

public function text(){
    return "hello";
}

這是我的路線

Route::get('/text',[MemberController::class,'text']);

所以,基本上它無法讀取我創建的新路線。 提前致謝

希望您使用 laravel 8 及以上版本應該是您的 controller 代碼(MemberController.php)

<?php

namespace App\Http\Controllers;

class MemberController extends Controller{
   
    public function text(){
       return "hello";
    }
}

這應該是您的路線代碼(web.php)

<?php

use App\Http\Controllers\MemberController;

Route::get('/text',[MemberController::class,'text']);

您提供的代碼是不夠的,但您可以檢查以下內容。

  1. 查看您的路線是否未緩存。 運行php artisan route:clear以清除緩存的路由。
  2. 你在哪里定義了路線? If it's in the web.php file then, your actual url should be: http://localhost:8000/text.
  3. If it's in the api.php file then, your url should be: http://localhost:8000/api/text.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM