在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ vue開(kāi)發(fā)測(cè)試過(guò)程中l(wèi)ocalhost環(huán)境下,如何從后臺(tái)取數(shù)據(jù)

vue開(kāi)發(fā)測(cè)試過(guò)程中l(wèi)ocalhost環(huán)境下,如何從后臺(tái)取數(shù)據(jù)

開(kāi)發(fā)過(guò)程中我們打開(kāi)的是localhost:8080,那比如后臺(tái)接口是http:www.cream.com/clt/getuse...。這樣肯定調(diào)不到接口中的數(shù)據(jù),那該怎么處理呢。

回答
編輯回答
編輯回答
遲月

這個(gè)需要配置代理:
如果是vue-cli的腳手架,需要用npm安裝http-proxy-middleware,然后再在修改config/index.js,代碼如下(注意不是直接粘貼,需要自己修改,和nginx的配置很像):

  dev: {
    env: require('./dev.env'),// 使用 config/dev.env.js 中定義的編譯環(huán)境
    port: 8080,// 運(yùn)行測(cè)試頁(yè)面的端口
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',// 編譯輸出的二級(jí)目錄
    assetsPublicPath: '/',// 編譯發(fā)布上線路徑的根目錄,可配置為資源服務(wù)器域名或 CDN 域名
    proxyTable: {
        '/iantooData/': {
            target: 'http://localhost:80/gitweb',
            pathRewrite: {
              '^/mspapi/': '/'
            }
        }

    }, // 需要 proxyTable 代理的接口(可跨域)
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false // 是否開(kāi)啟 cssSourceMap
  }

2.如果是nuxt腳手架:用npm安裝axios 和 proxy修改nuxt.config.js文件,新增配置如下:

modules: [
      '@nuxtjs/axios',
      '@nuxtjs/proxy'
    ],
  proxy: [
      ['/iantooData/', { target: 'http://localhost:80/' }]
  ]

3:如果是自己寫(xiě)的腳手架,...... 自己會(huì)寫(xiě)腳手架連代理都不會(huì)配嗎?

2018年5月22日 09:47