【发布时间】:2019-03-02 21:30:21
【问题描述】:
我正在尝试验证页面组件中的路由参数,如下所示:
async validate({ params, store }) {
await store.dispatch(types.VALIDATE_PARAMS_ASYNC, params.id)
}
然后在店里:
async [types.VALIDATE_PARAMS_ASYNC]({state, commit, dispatch}, payload) {
try {
const res = await this.$axios.$post('/api/params/validate', {
params: payload
})
commit(types.MUTATE_SET_INFO, res.data) // this mutation is in another module. This doesn't work either
return true
} catch(e) {
return false
}
}
这根本不起作用。即使我输入了无效的参数,它仍然会加载页面。请帮忙!
【问题讨论】:
标签: javascript vue.js async-await nuxt.js