Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms Vue中的自定义表单操作_Forms_Laravel_Vue.js - Fatal编程技术网

Forms Vue中的自定义表单操作

Forms Vue中的自定义表单操作,forms,laravel,vue.js,Forms,Laravel,Vue.js,我正在Vuejs组件模板中使用表单。我不想定义完整的静态URL。页面URL如下所示 表格须于。 但是使用 <form action = "comments" method ="POST"> 转到而不是。如何做到这一点?。提前谢谢。您可以在routes文件routes/web.php中为帖子路径命名: 例如: Route::post('/comments', 'SomeController@store')->name('postComment'); 通常情况下,您可以在刀片视

我正在Vuejs组件模板中使用表单。我不想定义完整的静态URL。页面URL如下所示 表格须于。 但是使用

<form action = "comments" method ="POST">

转到而不是。如何做到这一点?。提前谢谢。

您可以在routes文件routes/web.php中为帖子路径命名:

例如:

Route::post('/comments', 'SomeController@store')->name('postComment');
通常情况下,您可以在刀片视图中使用表单中的命名路由:

<form action="{{ route('postComment') }}" method="POST">
</form>
在这种情况下,如果使用Vue组件,则可以通过“后命令”路由

<component post-route="{{ route('postComment') }}"></component>
然后,接受Vue组件文件中的属性:

<template>
 <form action="this.post-route" method="POST"></form>
</template>

<script>
export default {
 props: ['post-route']
}
</script>

您可以在routes文件routes/web.php中为post路由指定一个名称:

例如:

Route::post('/comments', 'SomeController@store')->name('postComment');
通常情况下,您可以在刀片视图中使用表单中的命名路由:

<form action="{{ route('postComment') }}" method="POST">
</form>
在这种情况下,如果使用Vue组件,则可以通过“后命令”路由

<component post-route="{{ route('postComment') }}"></component>
然后,接受Vue组件文件中的属性:

<template>
 <form action="this.post-route" method="POST"></form>
</template>

<script>
export default {
 props: ['post-route']
}
</script>

对于ajax调用,我使用的是axios,它有axios.default.baseUrl='yourBaseUrl'


yourBaseUrl是在每次ajax调用之前添加的。

对于ajax调用,我使用的是axios,它有axios.default.baseUrl='yourBaseUrl'


您的BaseURL是在每次ajax调用之前添加的。

Try action=/commentsReady已尝试但不起作用。您的路由是否分组在任何前缀下?Try action=/commentsReady已尝试但不起作用。您的路由是否分组在任何前缀下?我在blade.php中使用了:post route={{json_encoderoute'login},现在可以工作了!我在blade.php中使用了:post-route={{json_-encoderoute'login}},现在可以使用了!