javascript - vue-resource 怎么获取 express 的数据?

查看:94
本文介绍了javascript - vue-resource 怎么获取 express 的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

    mounted() {
        this.$nextTick(function(){
            this.$http.get('http://127.0.0.1:3000/api/articals').then((response) => {
                console.log(response)
                this.articals = response.data;
            },(response) => {
                // console.log(response)

            });
        })
    },    

vue的端口是8080,express端口是3000.
想在vue-resource中通过/api/articals获取数据。
这两个端口应该怎么配置啊?

解决方案

配置proxyTable

proxyTable: {
   '/api': {
      target: 'http://localhost:3000',
      changeOrigin: true
   }
}

这篇关于javascript - vue-resource 怎么获取 express 的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆