【问题标题】:How to Give Link In Menu to go menu page (laravel 4.2)如何在菜单中提供链接以转到菜单页面(laravel 4.2)
【发布时间】:2018-02-24 05:08:20
【问题描述】:

你好朋友感谢查看我的问题!!

我无法激活我的菜单链接

我的查看文件代码

<div class="sign-up-right">
    <a href="{{ URL::route('singup') }}">Sign Up</a>
</div>

我的控制器文件(MyCon.php)

public function singup(){
    return View::make('preview',['preview'=>'signup.php']);
}

我的路线文件代码

Route::get('/', 'MyCon@index');
route::get('admin', array('user'=>'Admin@index'));

Route::get('/login',function(){ return View::make('preview',['preview'=>'login.php']);});

Route::get('singup', ['as' => 'signup', 'uses' => 'MyCon@signup']);

但是当我点击注册链接时,它会显示错误

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException



    return new Response('', 200, array('Allow' => implode(',', $others)));
        }))->bind($request);
    }
    $this->methodNotAllowed($others);
}

protected function methodNotAllowed(array $others)
{
    throw new MethodNotAllowedHttpException($others);
}

protected function check(array $routes, $request, $includingMethod = true)

请帮助我的链接成功 谢谢

【问题讨论】:

  • 不相关,但您到处都拼错了“注册”。 EDIT** 实际上它可能是相关的,因为你拼写正确,而其他所有尝试都错误。
  • 您发布的函数不完整,因此很难真正确定问题所在,但是拼写不一致和格式不佳会导致很多问题。让代码变得漂亮是值得的。你会明白为什么。

标签: php laravel laravel-5 laravel-4


【解决方案1】:

尝试为您的路线命名可能会解决您的问题

Route::post('singup', function(){ return View::make('preview',['preview'=>'signup.php']);});

【讨论】:

  • 调用未定义的方法 Illuminate\Routing\Route::name()
  • Route::post('singup', function(){ return View::make('preview',['preview'=>'signup.php']);});试试这个
  • 在注册页面上再次显示此 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
【解决方案2】:

由于您使用的是简单的a href 链接,因此您需要将路由更改为Route::get

Route::get('singup', ['as' => 'signup', 'uses' => 'MyCon@signup']);

另外,修复链接:

<a href="{{{ URL::route('signup') }}}">Sign Up</a>

【讨论】:

  • 方法 [注册] 不存在。此错误显示请帮助兄弟
  • 调用未定义的方法 Illuminate\Routing\Route::name()
  • @akashjha 哦,您使用的是 4.2。固定的。另外,按照我的说明更新链接。
  • 和 Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException 之类的错误
  • @akashjha 确保视图以.blade.php 结尾。另外,请显示整个路线文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多