1.vue專案為了打包後運維人員能夠修改後台服務位址,所以使用了ajax同步請求,但是chrome給了警告⚠️
#我的專案的根目錄是可以要求到的,然後和相對應的位址拼接的。
let baseUrl
import { 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 = jsonRead.
})
// 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/.