Non*_*one 0 laravel vue.js laravel-5
我在 vue.js 中有一个值数组,但问题是我需要将这些值传递给控制器。我该怎么做,或者这是一种错误的方式?
这是在我的 vue.js 中获取值的地方:
additional_features: this.additionals_features
this.$http.patch('/profile/'+ user_id +'/property/'+ property_id +'/edit', property_credentials).then(function(response) {
$("html, body").animate({ scrollTop: 0 }, "slow");
this.property_status = true;
this.property_success_update_message = response.data.successUpdateMsg;
} , function(response) {
$("html, body").animate({ scrollTop: 0 }, "slow");
this.property_status = false;
this.property_errors = response.data
});
Run Code Online (Sandbox Code Playgroud)
这是我的控制器
$additional_features = $request->input('additionals_features');
Run Code Online (Sandbox Code Playgroud)
这是我的 html:
<input type="hidden" v-model="property_credentials.additional_features" name="additional_feature[]" value="@{{property_credentials.additional_features}}" />
Run Code Online (Sandbox Code Playgroud)
您可以使用vue-resource并使用 post 发送它:
new Vue({
el: '#app',
data: {
token: '{{ csrf_token() }}',
property_credentials: {
additionals_features: [],
}
},
methods: {
submit: function() {
this.$http.post('/your-api-url', {
'_method': 'patch',
'_token': this.token, // You must pass this token on post requests
'additionals_features': this.property_credentials.additionals_features,
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
数据将直接到达您的控制器,因此您可以
$additional_features = $request->get('additionals_features');
Run Code Online (Sandbox Code Playgroud)
一旦数据到达控制器,你如何处理这些数据,这取决于你。
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |