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获取数据。
这两个端口应该怎么配置啊?

阅读 2.4k
1 个回答

配置proxyTable

proxyTable: {
   '/api': {
      target: 'http://localhost:3000',
      changeOrigin: true
   }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题