npm i axios -S
import Axios from 'axios'
Vue.prototype.$axios = Axios //在main.js引入axios,因為其不屬于vue全家桶,所以將其掛載在vue原型上,實現(xiàn)全局使用
在項目config目錄下的修改 index.js文件
proxyTable: {
"/api":{
target: "http://screen.rdxsaj.com",
changeOrigin: true,
pathRewrite: {
'^/api':''
}
}
},
配置完后記得重啟項目才會生效
that.$indicator.open({
text:'正在登錄...'
})
var obj = {
token:'1AEA4006B1F1F19E26499A75B456EAFD',
deviceSerial:'802883535,D11282193',
appkey:5001,
time:1619071028
}
var url = '/api/v1/vedio';
that.$axios.post(url,obj)
.then(response => {
console.log(response);
setTimeout(function(){
that.$indicator.close();
that.$toast({
message:'登錄成功',
// iconClass: 'icon icon-success',
duration:1000
})
},1000);
}).catch(error => {
console.log(error);
})
跨域完成,可以請求到接口了
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號