当前文档中尚不清楚,因为fetch
方法发生了很大变化。据我了解,在文档中它说:
fetch(context) 已被弃用,您可以在页面中使用匿名中间件:middleware(context)
所以context
不再可用了?那么将什么传递给新 fetch
方法呢?
以及如何store
访问context
?比如2.12.2之前,我们可以使用fetch
如下方法:
// pages/index.vue
async fetch ({ store }) {
await store.dispatch('....')
},
所以,我假设上面的代码将来不会很快在 Nuxt 3 中运行。那么当你在一个页面上时如何填充存储数据呢?
目前,您似乎仍然可以访问新方法中context
的第一个参数。未来呢? fetch