vue3.0解决跨域

    技术2024-03-26  99

    vue.config.js

    devServer: { proxy: { //设置代理 '/ip': { target: "http://xxxxxx.com/", // target host ws: true, // proxy websockets changeOrigin: true, // needed for virtual hosted sites pathRewrite: { } }, }, },

    注意: 1.改了必须重新启动 2.原先的公用的url 必须删除

    使用

    ajax.ajaxGet(param,"/ip/getList").then(res=>{ callback(res) // callback(commond.doAjaxData(res.data)) })

    接口地址原先可能是http://xxxxxxxxx/ip/a/b 只要写成/ip/a/b

    Processed: 0.010, SQL: 10