💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ### nuxt.js 跨域配置 * [ ] 安装官方 axios ``` npm i @nuxtjs/axios @nuxtjs/proxy -D ``` Or ``` yarn add @nuxtjs/axios @nuxtjs/proxy --dev ``` ***** * [ ] 在 nuxtjs.config.js 配置文件最后添加下面模块,并且设置代理 ``` modules: [ '@nuxtjs/axios', '@nuxtjs/proxy' ], proxy: [ [ '/api', { target: 'http://localhost:7001/', // api host pathRewrite: { '^/api': '/' } } ] ], ``` ***** * [ ] 组件中访问 >[danger] 注意!!! Axios 要大写!!! ``` <script> import Axios from 'axios'; export default { components: { Logo }, data() { return { list: [] } }, async asyncData() { const { status, data:{list} } = await Axios.get('http://localhost:7001/api/v1/city') if (status === 200) return { list } } } </script> ```