搜尋

首頁  >  問答  >  主體

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

黄舟黄舟2845 天前474

全部回覆(1)我來回復

  • 高洛峰

    高洛峰2017-05-16 16:51:20

    你用的是webpack嗎?webpack的話是這樣用

    import  vueResource from 'vue-resource'
    Vue.use(VueResource);

    回覆
    0
  • 取消回覆