https://github.com/bartflyian/wx-front-with-server/tree/master/wx-webfront 客户端文件夹代码地址。
一,分一个客户端的文件夹出来。用vue-cli初始化一个vue项目。自己添加vue.config.js,安装配置axios,配置前端代理

1.简单的在app.vue中写写样式和组件。主要来看看访问接口:

运行客户端,npm start,最后效果:

二,在这里又试了下在node服务器端的接口转发。添加 /comments 接口 ,当客户端访问接口时,在服务器端下访问网易公共接口,获取数据后可以进行数据的处理,再返回给客户端。这种方式在一些需要前端进行大量逻辑计算时,能大大减轻前端的负载,也容易进行接口的合并。



具体代码看看git上的代码吧
网友评论