您好,欢迎来到花图问答。
搜索
您的当前位置:首页vue-resource的使用

vue-resource的使用

来源:花图问答

vue-resource是Vue的插件,用来与远程服务器端通信,相当于ajax

在项目中安装

npm install vue-resource --save

引入

在main.js中

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

使用

<script>
export default {
  name: 'hello',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    } 
  },
  created:function (){
        this.$http.get('/api/cakeList/').then((response) => {
        console.log(response.data);
      })
    }
}
</script>

运行的时候,要启动Apache

Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务