![](/img/trans.png)
[英]Firebase: how to add auto-generated document id to the document in svelte?
[英]How to get an auto-generated id by using add()?
我正在使用節點、vue、firestore。
當我單擊使用 add() 創建的文檔時,我想將 go 轉到 url 是文檔的自動生成 ID 的頁面。
我曾經
setup () {
const moveToCreate = () => {
router.push({
name: 'Boadrdid',
params: {
id: Boardid
}
})
}
} boardid.vue
{
path: '/board/:id',
name: 'Boardid',
component: Boardid,
props: true
} router/index.js
移動頁面,但是除了這個還有其他方法嗎?
我想獲得自動生成的 id 因為要使用 db.collection.doc(我應該在這里做什么).delete
您可以像在代碼中那樣做:
router.push({name: 'Boadrdid', params: { id: Boardid }})
或者用更短的方式:
const id = 12;
router.push({name: 'Boadrdid', params: { id }})
或者這樣:
const id = 12;
router.push({ path: `/board/${id}` })
您可以在此鏈接中閱讀有關 Vue 編程導航的更多信息https://router.vuejs.org/guide/essentials/navigation.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.