【发布时间】:2021-10-30 15:08:39
【问题描述】:
我的 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');
}
【问题讨论】:
-
``` Route::get('/privacy-policy', 'SecurityImplementationController@privacy'); ``` 为什么你的路由开头有斜线?你试过删除它吗?
-
你应该在你的函数中使用:
window.location.href=... -
不,它也不起作用
-
在 vue.js 中你应该绑定 onclick 像这样 "v-on:click" 而不是 ':onClick'