导入方式如下: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的话是这样用