感谢阅读我的问题。
我已经阅读了我的问题
VUE JS 2 + WEBPACK Cannot read property 'get' of undefined VUE RESOURCE
但是我的系统无法读取 Vue var :(
我有一个名为 app.vue 的 vue 组件,我需要使用 vue-resource 从我的帖子中获取数据。但是很多时候的错误是:
TypeError: Cannot read property 'post' of undefined
at VueComponent.loadingProcess
你有解决的办法吗?
我的应用程序.vue
<script>
var Vue = require('vue');
//Vue.use(require('vue-resource'));
//Vue.use();
export default {
data () {
return {
msg: 'Hello from vue-loader! nice!',
user: {}
}
},
mounted: function () {
this.loadingProcess();
},
methods: {
loadingProcess: function () {
var urlPost;
var answQSend = {...};
var that = this;
var jsonSend = {
"form_data": answQSend,
"prod_id": 3
};
Vue.$http.post(urlPost, jsonSend, {
"headers": {
"content-type": "application/json"
}
})
.then(function(response) {
})
...
提前致谢!
最佳答案
首先感谢@Bert 耐心的帮我找到了解决方案
在我的 main.js 中,我更改了这一行
var VueResource = require('vue-resource');
对于
import VueResource from "vue-resource"
并使用
Vue.use(VueResource);
然后,在我的应用程序 vue 组件中,我更改了
Vue.http.post
为了
this.$http.post
这样我们就修复了错误!
关于webpack - 无法读取未定义的 vue 的属性 'post',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43646844/