我想使用“vue-resource”發(fā)布表單數據,但出現錯誤。我用 vue-cli 和 vuetify 編寫了代碼。錯誤[Vue 警告]:v-on 處理程序中的錯誤:“TypeError:this.$http.post(...).error 不是函數”應用程序.vue<template> <v-app> <v-main> <v-container class="px-0"> <v-form ref="form" @submit="addEvent"> <p class="text-uppercase">Question?</p> <v-radio-group v-model="newEvent.select1" row> <v-radio label="aaa" value="aaa"></v-radio> <v-radio label="bbb" value="bbb"></v-radio> </v-radio-group> <input type="submit" depressed color="primary" value="OK!"> </v-form> </v-container> </v-main> </v-app></template><script>export default { name: 'App', data () { return { users: [], newEvent: { select1: '', } } }, methods: { addEvent: function (e) { e.preventDefault() if (this.isValid) { console.log("success") console.log("select1: " + this.newEvent.select1) this.$http.post('URL..', this.newEvent, function (data, status, request) { console.log("post success") console.log(status) }).error(function (data, status, request) { console.log("post failed") }) }else{ console.log("need edit") } }, }, computed: { isValid: function () { var valid = true for (var key in this.data) { if (!this.data[key]) { valid = false } } return valid } },};</script> 我嘗試在 main.js 中寫“import VueResource from 'vue-resource'”,但是沒有效果。我該如何解決?
無法使用 vue.js 發(fā)布
慕姐4208626
2023-02-17 17:21:17