zoukankan      html  css  js  c++  java
  • vuebase-11._跨域处理

    1.跨域配置

    proxyTable: {
    '/xxx_api':{
    target: 'http://xxxcom',
    pathRewrite: {
    '^/xxx_api': ''
    },
    changeOrigin: true
    }
    }

    mains.js

    Vue.prototype.HOST = "/xxx_api"
    Vue.config.productionTip = false

    实例-------------------------------------------------------------------------------

    <template lang="html">
    <div class="hello">
    HelloWorld!
    </div>
    </template>

    <script>
    export default {
    name: 'HelloWorld',
    data() {
    return {
    msg: 'Welcome to Your Vue.js App'
    }
    },
    mounted() {
    /* this.$axios.get("xxxx")
    .then(res => {
    console.log(res.data)
    }).catch(error => {
    console.log(error);
    }) */
    /* this.$axios.post("xxx", {
    uers_id: "12345",
    password: "1234567890"
    }).then(res => {
    console.log(res.data)
    }).catch(error => {
    console.log(error)
    }) */
    /* axios({
    method: 'post',
    url: '/user/12345',
    data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
    }
    }) */
    var url=this.HOST+"/v2/xxx/top250"
    this.$axios({
    method:'get',
    url:url
    }).then(res =>{
    console.log(res.data)
    }).catch(error=>{
    console.log(error)
    })
    }
    }
    </script>

    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    h1,
    h2 {
    font-weight: normal;
    }

    ul {
    list-style-type: none;
    padding: 0;
    }

    li {
    display: inline-block;
    margin: 0 10px;
    }

    a {
    color: #42b983;
    }
    </style>

  • 相关阅读:
    [剑指 Offer 11. 旋转数组的最小数字]
    进程描述符(PCB)
    [剑指 Offer 57. 和为s的两个数字]
    Linux netstat命令
    kafka2.3.X配置文件
    docker
    shell操作mysql数据库
    Linux文件查找之find命令
    sed 切割日志文件
    Linux文本处理之awk
  • 原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11333752.html
Copyright © 2011-2022 走看看