Cannot read property #39;post#39; of undefined vue(无法读取未定义 vue 的属性“帖子)
问题描述
感谢您阅读我的问题.
我已经阅读了我的问题
VUE JS 2 + WEBPACK无法读取未定义 VUE RESOURCE 的属性get"
但是我的系统没有读取 Vue var :(
But my system no read Vue var :(
我有一个调用 app.vue 的 vue 组件,我需要使用 vue-resource 从我的帖子中获取数据.但是很多时候的错误是:
I have a vue component calls app.vue and i need to use vue-resource to get data from my post. But the error a lot times is:
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) {
})
...
提前致谢!
推荐答案
首先感谢@Bert 耐心的帮我找到了解决方案
First of all, thanks to @Bert who was patient and helped me find the solution
在我的 main.js 中,我更改了这一行
In my main.js, i changed this line
var VueResource = require('vue-resource');
为
import VueResource from "vue-resource"
并使用
Vue.use(VueResource);
然后,在我的应用程序 vue 组件中我更改了
Then, in my app vue component i changed
Vue.http.post
对于
this.$http.post
这样我们就修复了错误!
That way we fixed the error!
这篇关于无法读取未定义 vue 的属性“帖子"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法读取未定义 vue 的属性“帖子"
基础教程推荐
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
