您将如何在Vuex中设置动态axios呼叫?例如/ api / data / {id},其中ID链接到laravel数据库中的用户ID
答案 0 :(得分:0)
您可以执行以下操作来访问路由器动态参数:this.$route.params.id
通过axios获取用户信息的示例:
<template></template>
<script>
export default {
async created() {
const userInformation = await axios.get(`user/${this.$route.params.userId}`);
}
}
</script>
这是假设您使用以下内容定义的路由:
const routes = [
{ path: 'user/:id', name: 'user-view', component: ComponentA }
]