2017-04-27 159 views
1

感谢您阅读我的问题。无法读取属性'后'的undefined vue

我看了一下我的问题

VUE JS 2 + WEBPACK Cannot read property 'get' of undefined VUE RESOURCE

但是我的系统中没有读Vue的变种:(

我有一个VUE组件调用app.vue,我需要使用VUE资源以从我的后得到的数据,但错误很多次是:?

TypeError: Cannot read property 'post' of undefined 
at VueComponent.loadingProcess 

不要ü有想法解决它

我app.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) { 

      }) 
      ... 

提前感谢!

回答

5

首先,感谢@Bert谁是耐心帮我找到解决

在我main.js,我改变了这一行

var VueResource = require('vue-resource'); 

import VueResource from "vue-resource" 

并使用

Vue.use(VueResource); 

然后,在我的应用程序VUE成分,我改变

Vue.http.post 

对于

this.$http.post 

这样,我们固定的错误!

相关问题