laravel - vue-resourse has been imported, but the front end still reports an error!
黄舟
黄舟 2017-05-16 16:49:20
0
1
453

The import method is as follows: import 'vue-resource'
Component usage 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>

The error message is: cannot read property "post" of ubdefined

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
小葫芦

Are you using webpack? This is how you use webpack

import  vueResource from 'vue-resource'
Vue.use(VueResource);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template