Nuxt图像在页面更改时不断中断



我的Nuxt页面上显示了图像,但每当我离开它返回时,图像就会中断,我不知道为什么。

我的代码中有这个

<img :src="baseUrl + 'storage/'+ front.featured_image" alt="post-title" />

和我的脚本

data: () => ({
frontpage: [],
baseUrl: process.env.BASE_URL
}),
async asyncData({ $axios }) {
const response = await $axios.get('/api/frontpage')
return { frontpage: response.data.posts }
},

我有一个.env文件,里面有以下内容BASE_URL=http://localhost/nuxt.config.js

env:{
baseUrl: process.env.BASE_URL || 'http://localhost/'
}

我的API是使用laravel构建的,它是从http://localhost/加载的,但Nuxt在页面更改时一直返回到localhost:3000

您可以在此处查看我以前的答案:https://stackoverflow.com/a/67705541/8816585

这可能有助于

export default {
publicRuntimeConfig: {
baseUrl: process.env.BASE_URL,
},
}

否则,Axios的此配置可能也会有所帮助!

最新更新