laravel - 已导入vue-resourse,前端依旧报错!
本文介绍了laravel - 已导入vue-resourse,前端依旧报错!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
导入方式如下:import 'vue-resource'
组件使用post:
<script>
export default{
data () {
return {
formSendCodeField:{
phone: '',
code: ''
}
}
},
methods: {
sendCode () {
this.$http.post('/api/phone/code', {phone: this.phone})
.then(function (response) {
console.log(response);
}, function(error){
console.log(error)
})
}
}
}
</script>
报错信息为:cannot read property "post" of ubdefined
解决方案
你用的是webpack吗? webpack的话是这样用
import vueResource from 'vue-resource'
Vue.use(VueResource);
这篇关于laravel - 已导入vue-resourse,前端依旧报错!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文