Vue JS 按钮点击重定向到 404
Vue JS button click redirecting to 404
我的 laravel/Vue 应用程序中有以下组件。
当用户单击此按钮时,我想将他们发送到 privacy blade
。 (sample.site/privacy-policy)
<template lang="">
<div class="verbatimGameLayout__footer">
<FeedbackButton label="Vie privée" :onClick="goToFeedback" />
<SaveButton label="sauvgarder" />
</div>
</template>
export default {
components: {
FeedbackButton
},
methods: {
goToFeedback() {
window.location = "/privacy-policy";
}
}
};
我的路线如下 web.php
,
Route::get('/privacy-policy', 'SecurityImplementationController@privacy');
当我尝试访问 URL 时,它一直给我一个 404 错误...
以下是与上述问题相关的控制器(SecurityImplementationController.php
)方法
public function privacy() {
return view('privacy');
}
你为什么不清理你的路由缓存并检查
php artisan route:clear
php artisan route:cache
我建议您使用 vue-router
进行此类操作。
使用vue-router
你可以像这样轻松设置路由:
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
然后你可以这样调用路由:
this.$router.push('/bar')
在文档中查看更多信息:Vue Router | Getting Started
我的 laravel/Vue 应用程序中有以下组件。
当用户单击此按钮时,我想将他们发送到 privacy blade
。 (sample.site/privacy-policy)
<template lang="">
<div class="verbatimGameLayout__footer">
<FeedbackButton label="Vie privée" :onClick="goToFeedback" />
<SaveButton label="sauvgarder" />
</div>
</template>
export default {
components: {
FeedbackButton
},
methods: {
goToFeedback() {
window.location = "/privacy-policy";
}
}
};
我的路线如下 web.php
,
Route::get('/privacy-policy', 'SecurityImplementationController@privacy');
当我尝试访问 URL 时,它一直给我一个 404 错误...
以下是与上述问题相关的控制器(SecurityImplementationController.php
)方法
public function privacy() {
return view('privacy');
}
你为什么不清理你的路由缓存并检查
php artisan route:clear
php artisan route:cache
我建议您使用 vue-router
进行此类操作。
使用vue-router
你可以像这样轻松设置路由:
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
然后你可以这样调用路由:
this.$router.push('/bar')
在文档中查看更多信息:Vue Router | Getting Started