我正在尝试在商店被填充后加载页面标题。然而,我不知道如何正确地做。 这是我所理解的应该做的,但它不工作。它说对象还没有加载(Cannot read property 'p_pdf_ad_headlines' of undefined)。
我在Nuxt中怎么做?
async fetch({ store, params }) {
await store.dispatch('getMixedLanding', { id: params.id })
},
head() {
return {
title: this.$store.state.landing.p_pdf_ad_headlines.page_headline
.text
}
}
我想明白了。对于其他人来说,我所做的唯一一件事就是把 "我 "的名字写在了 "我 "的名字上。dispatch
中的功能 fetch
的功能。而 head
保持不变。
async fetch({ store, params }) {
const response = await axios.get(
'http://example.com/item/' + params.id + '/'
)
store.commit('mixedResponse', response)
},