安全,輕鬆的Axios與Nuxt.js集成

modules: [
    // Doc: https://github.com/nuxt-community/axios-module#usage
    '@nuxtjs/axios'
  ],
  /*
  ** Axios module configuration
  */
  axios: {
    proxy: true,
    prefix: '/api/',
    credentials: true
    // See https://github.com/nuxt-community/axios-module#options
  },

  proxy: {
    '/api/': { 
      target: 'https://h5api.zhefengle.cn',//這個網站是開源的能夠請求到數據的
      pathRewrite: {
         '^/api/': '/',
         changeOrigin: true
      }    
    }
  },

而後在你的頁面能夠直接請求數據了html

mounted() {
        this.$axios.get("/index.html").then(res=>{
            console.log(res)
        })
    },

https://www.jianshu.com/p/7d105f3e28f1ios

相關文章
相關標籤/搜索