这里给大家推荐一款免费迭代 二开便捷的商城项目:源码直通车>>>
应公司需求,接口需要对接vue,记录一下碰到的问题
开发环境:
系统:windows10
php开发环境:PHPstudy(PHP5.6.27 NTS+Apache+MySQL)
前端:vue2.x
后端:thinkPHP5.0.24
一、接口调用
前提是安装了axio
main.js中引用
import axios from 'axios'
Vue.prototype.$http = axios
get方式:
httpGet(){
this.$http.get('apis/webapi/index/product')
.then( (res) => {
this.subnav=res.data;
})
}
post方式:
httpPost(){
this.$http.post('apis/webapi/index/product',{id:id})
.then( (res) => {
this.subnav=res.data;
})
}
二、跨域问题