首頁  >  問答  >  主體

javascript - vue專案為了打包後運維人員能夠修改後台服務位址,所以使用了ajax同步請求,但是chrome給了警告⚠️

1.vue專案為了打包後運維人員能夠修改後台服務位址,所以使用了ajax同步請求,但是chrome給了警告⚠️

  1. #我的專案的根目錄是可以要求到的,然後和相對應的位址拼接的。

    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'
    }

    1. 但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/.

淡淡烟草味淡淡烟草味2711 天前1085

全部回覆(2)我來回復

  • 为情所困

    为情所困2017-05-17 09:59:30

    這個警告是說你使用了async=false的ajax,跟你打包什麼的沒關係

    回覆
    0
  • ringa_lee

    ringa_lee2017-05-17 09:59:30

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

    回覆
    0
  • 取消回覆