vue相关

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。通过代理就实现了跨域访问。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值