Vuejs无法提交表单Ajax
我想通过modal Semantic UI和Vuejs提交数据。但是我的表单不能通过Ajax提交数据。我发现这个问题很累,也许有人能帮我 我的看法是这样的Vuejs无法提交表单Ajax,ajax,laravel,vue.js,Ajax,Laravel,Vue.js,我想通过modal Semantic UI和Vuejs提交数据。但是我的表单不能通过Ajax提交数据。我发现这个问题很累,也许有人能帮我 我的看法是这样的 <form v-on:submit.prevent="addProductCategory" class="ui form"> <div class="content"> <div class="description"> <di
<form v-on:submit.prevent="addProductCategory" class="ui form">
<div class="content">
<div class="description">
<div class="field" v-bind:class="{'has-error': input.errorsAddProductCategory.name}">
<label for="name">Name</label>
<input v-model="input.addProductCategory.name" type="text" id="name" name="name">
<div class="help-block" v-if="input.errorsAddProductCategory.name"
v-text="input.errorsAddProductCategory.name[0]"></div>
</div>
</div>
</div>
<div class="actions">
<div class="ui black deny button">
No
</div>
<button type="submit" class="ui positive right button">Add</button>
</div>
</form>
<script type="text/javascript">
const CSRF_TOKEN = '{{ csrf_token() }}';
const URLS = {
productCategory: {
addProductCategory: '{{ route('product-category.store') }}',
}
};
</script>
和Vuejs
var app = new Vue({
el: "#app",
data: function () {
return {
input: {
addProductCategory: {
name: ""
},
errorsAddProductCategory: [],
editProductCategory: {
name: ""
},
errorsEditProductCategory: []
}
};
},
methods: {
addProductCategory: addProductCategory,
}
});
使用jQuery处理请求有什么原因吗?Axios是一个非常棒的http处理程序,专门为vuejs设计。@Joe Axios不是为Vue设计的。它是一个通用HTTP客户端。Vue中的ajax可以接受jQuery。您看到了什么错误?@BertEvans没有错误。只是仍在第页,不做任何回应。。但是,当我尝试显示警报时,这是一项工作。addProductCategory方法是否被调用?它会返回成功还是错误?您使用jQuery处理请求有什么原因吗?Axios是一个非常棒的http处理程序,专门为vuejs设计。@Joe Axios不是为Vue设计的。它是一个通用HTTP客户端。Vue中的ajax可以接受jQuery。您看到了什么错误?@BertEvans没有错误。只是仍在第页,不做任何回应。。但是,当我尝试显示警报时,这是一项工作。addProductCategory方法是否被调用?这是成功还是错误?
var app = new Vue({
el: "#app",
data: function () {
return {
input: {
addProductCategory: {
name: ""
},
errorsAddProductCategory: [],
editProductCategory: {
name: ""
},
errorsEditProductCategory: []
}
};
},
methods: {
addProductCategory: addProductCategory,
}
});