【发布时间】:2020-09-01 17:32:07
【问题描述】:
我正在尝试创建一个功能,个人可以创建列表,其他用户可以提交申请。 ATM 我不太明白如何从以下网址获取 ID:
'http://localhost:3000/listings/2/'
我有预感这需要 Vue 路由器和 $route.params.id?基本上我想在我的表单中列出用户申请的列表的 ID。在这种情况下,它将是 '2'
我的文件夹结构是.../listings/_id/index.vue
这是我在 DRF 中的 user_applications 模型的后端:
listing = models.ForeignKey(Listings, on_delete=models.CASCADE, default="1")
这是前端:我希望我可以在脚本中使用 props 值,但它似乎只能在模板中使用,哦,好吧。
data: () => ({
form: {
role: null,
company: null,
status: "Pending"
// listing: listings.id
}
}),
props: ["listings"],
computed: {
...mapGetters(["loggedInUser"])
},
methods: {
submit() {
this.$axios
.post("/api/v1/apps/", this.form)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
}
}
【问题讨论】:
标签: vue.js django-models nuxt.js