简体   繁体   English

如何使用 add() 获取自动生成的 id?

[英]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.

相关问题 Firebase:如何将自动生成的文档 ID 添加到 svelte 中的文档? - Firebase: how to add auto-generated document id to the document in svelte? 如何在 firebase Firestore 中从.set() 中获取自动生成的 ID? - How to get the auto-generated ID from .set() in firebase Firestore? 获取自动生成的 ID - Firebase - Get the auto-generated id - Firebase 如何在ReactJS中制作自动生成的ID - How to make auto-generated ID in ReactJS 如何在 Firestore Web V9 的子集合中获取新创建的文档的自动生成的 ID? Javascript/反应 - How to get auto-generated ID of newly created document in a subcollection in Firestore Web V9? Javascript/React 如何删除firestore中自动生成的id数据 - How to delete auto-generated id data in firestore 如何为每个自动生成的按钮分配不同的ID? - How to assign a different ID to every auto-generated button? 如何为点击的文档获取自动生成的 id - How to obtain auto-generated id for clicked documents 如何使用 javascript 隐藏 jinja 自动生成的 forms? - How to hide jinja auto-generated forms using javascript? 如何从 Windows Azure 服务器脚本中插入的项目中获取自动生成的 ID? - How to obtain the auto-generated ID from an item being Insterted in a Server Scripts, Windows Azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM