0

在我的页面上,我有一个异步 fetch() 方法,用于从 api 获取一些数据,以将其显示在页面上。代码如下所示:

data(){
    return{
        name : "",

    }

},

async fetch()
{
    console.log(this.$route.params.slug)
    const d2 = await axios.get('http://localhost:8000/Movie/'+this.$route.params.slug)
    const d1 = await axios.get('http://localhost:8000/Episodes/'+this.$route.params.slug+'/0')
    console.log(d2.data);
    console.log(d1.data)

    this.name = d2.data.name

}

当我尝试使用不同页面上的 nuxt 链接加载页面时,或者如果我返回该页面,则不会调用 fetch 方法。我必须每次使用 f5 重新加载页面才能再次查看数据。

4

0 回答 0