[英]How to get an auto-generated id by using add()?
I am using node, vue, firestore.我正在使用节点、vue、firestore。
I want to go to a page where the url is the auto-generated id of the document when I click on a document created using add().当我单击使用 add() 创建的文档时,我想将 go 转到 url 是文档的自动生成 ID 的页面。
I used to我曾经
setup () {
const moveToCreate = () => {
router.push({
name: 'Boadrdid',
params: {
id: Boardid
}
})
}
} boardid.vue
{
path: '/board/:id',
name: 'Boardid',
component: Boardid,
props: true
} router/index.js
to move page, but Is there any other way than this one?移动页面,但是除了这个还有其他方法吗?
I want to get auto-generated id Because to use db.collection.doc( what should i do here ).delete我想获得自动生成的 id 因为要使用 db.collection.doc(我应该在这里做什么).delete
You can do it the way you did in your code:您可以像在代码中那样做:
router.push({name: 'Boadrdid', params: { id: Boardid }})
Or in a shorter way:或者用更短的方式:
const id = 12;
router.push({name: 'Boadrdid', params: { id }})
Or this way:或者这样:
const id = 12;
router.push({ path: `/board/${id}` })
You can read more about Vue programmatic navigation in this link https://router.vuejs.org/guide/essentials/navigation.html您可以在此链接中阅读有关 Vue 编程导航的更多信息https://router.vuejs.org/guide/essentials/navigation.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.