您的位置:首頁技術文章
文章詳情頁

javascript - vue項目為了打包后運維人員能夠修改后臺服務地址,所以使用了ajax同步請求,但是chrome給了警告??

瀏覽:102日期:2022-12-09 09:06:18

問題描述

1.vue項目為了打包后運維人員能夠修改后臺服務地址,所以使用了ajax同步請求,但是chrome給了警告??

我的項目的根目錄是可以請求到的,然后和相對應的地址拼接的。

let baseUrlimport { Ajax } from ’./components/commonjs/ajax.js’Ajax.get(’./static/baseApi.json’, function (res) { let jsonRes = JSON.parse(res) console.log(’請求的內容:’, jsonRes.baseUrl) baseUrl = jsonRes.baseUrl tempstaticUrl = jsonRes.staticUrl tempmodelLoadedUrl = jsonRes.modelLoadedUrl})// let baseUrl = ’/CpyService’console.log(’當前訪問的后臺地址是:’, baseUrl)export default { authCode: baseUrl + ’/AuthImageCode/authCode’}

但是chrome的控制臺給出了警告:ajax.js?4a26:6 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help, check https://xhr.spec.whatwg.org/.

問題解答

回答1:

這個警告是說你使用了async=false的ajax,和你打包什么的沒關系

回答2:

考慮用jsonp的方式呢?用script標簽引入的數據,

標簽: JavaScript
国产综合久久一区二区三区