zoukankan      html  css  js  c++  java
  • iViewadmin数据请求跨域处理

    main.js中的要改成这样

    import axios from 'axios';
    var instance = axios.create({
    baseURL: 'http://192.168.10.67/api',
    timeout: 5000,
    });
    Vue.prototype.$axios = instance;

    在logo.vue页面

    var  params = {
    userName:__this.form.userName,
    userPwd:__this.form.password
    };
    if (__this.form.userName !== '' && __this.form.password !== '') {
    __this.$axios.post('/login/checkLogin',JSON.stringify(params), {
    headers: {
    "Content-Type":'application/json'
    }})
    .then(response=>{
    if(response.status == "200"){
    Cookies.set("token",response.data.data);
    if(response.data.msg =="success"){
    let admin_info = eval("("+response.config.data+")");
    console.log(admin_info);
    let ___this = __this;
    ___this.show = false;
    if (valid) {
    Cookies.set('user', ___this.form.userName);
    Cookies.set('password', ___this.form.password);
    ___this.$store.commit('setAvator', 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg');
    if (___this.form.userName === admin_info.userName && ___this.form.password === admin_info.userPwd) {
    Cookies.set('access', 0);
    } else {

    Cookies.set('access', 1);
    }
    ___this.$router.push({
    name: 'home_index'
    });
    }
    }else{
    console.log("登录失败");
    }
    }else {
    throw new Error("sss");
    }
    }).then(data=>{
    })
  • 相关阅读:
    HTML5画布(线条、渐变)
    HTML5画布(圆形)
    HTML5画布(矩形)
    HTML5拖放
    HTML5音频
    HTML5视频
    table添加正确的样式
    Mac上SublimeText3安装Emmet时PyV8安装问题
    PHP分页
    Mysql的limit用法
  • 原文地址:https://www.cnblogs.com/boonook/p/8949361.html
Copyright © 2011-2022 走看看