通过脚手架搭建起来的vue项目,遇到了常见的跨域问题,之前做项目跨域都是后台进行解决,这次因为是个人项目,只能 “自己动手,丰衣足食”
在根目录下的config文件夹下的index.js中修改proxyTable对象
在需要使用的地方通过api来代替
getCaptcha(){
if(!this.SignUp.phone){
alert('请输入手机号码!')
}else{
axios.post('/api/captcha/sent?phone=' + this.SignUp.phone,{
phone: this.SignUp.phone,
}).then((res)=>{
console.log('短信发送成功!')
console.log(res)
})
}
}