rem 公式:设计稿任意尺寸px*(设备屏幕px/设计稿尺寸px)/(font-size);
<script type="text/javascript">
!(function (win) {
var setBasicFontSize = function () {
var element = win.document.documentElement;
element.style.fontSize = element.clientWidth / 7.2 + 'px';
};
setBasicFontSize();
win.addEventListener("DOMContentLoaded", setBasicFontSize, false);
win.addEventListener("resize", setBasicFontSize, false);
})(window);
</script>
cardGift(){
var _v = this;
_v.$http.jsonp(_v.dataGbsURL + '/query/voucher/user/list', {
params: {
version: '1.0',
user_account: _v.username,
token:_v.token,
appplt: 'atvos',
appid: 'sn.tec.ppos.launcher',
format: 'jsonp',
cb: 'callback'
},
jsonp: 'callback',
jsonpCallback: 'callback'
}).then(function (res) {
if (res.data.code == 1000) {
}
}), function () {
};
}
分享以下:
https://blog.csdn.net/weixin_38070406/article/details/81294812
VUE跨域
首先在config/index.js中配置proxyTable
proxyTable: {
'/api':{
// target:'http://jsonplaceholder.typicode.com',
target:'http://localhost:9080',
changeOrigin:true,
pathRewrite:{
'/api':''
}
}
receive() {
var _v=this;
_v.$http.post('/apis/activity_4001_encourageExchange', {
mac : _v.macAdress,
actId:_v.actID,
sign:_v.sign,
token:_v.token,
username:_v.username,
}, {
emulateJSON: true
}).then(function (res) {
//console.log(res.data.statuSCode);
if(res.data.statuSCode==10000){
$('.modalbg').show();
$('.gift-succ-box').show();
this.lostFocus('sectionReceive');
this.onFocus("gift-succ-box");
this.changeStatus();
this.area = -1;
} else if(res.data.statuSCode==20001) {
$('.modalbg').show();
$('.gift-error-user-box').show();
this.lostFocus('sectionReceive');
this.onFocus("gift-error-user-box");
this.area = -1;
}
}),function(){
};
},
值得注意的是:
一定要设置 {emulateJSON: true},不然跨域不成功.
跨域在chrome浏览器中你看到的还是http://localhost:8080(即你启动vue的地址,而不是你服务器应用的地址),所以你看到不要惊讶,其实是跨域成功的。
http请求中要带上/api,经过index.js的代理会将/api去掉,浏览器中的访问地址为http://localhost:8080/api/amdatashift/login/user,然后实际的访问的地址是http://localhost:9080/amdatashift/login/user。通过代理就实现了跨域访问。