英文:
v1 function for uuid not working for react native expo?
问题
我有以下的代码:
const handlefb = async () => {
const fb = sRef(storage, `paramKey/${feedback + v1()}`);
uploadString(fb, todoDatafb).then((snapshot) => {
console.log('Uploaded new feedback')
})
根据 https://www.npmjs.com/package/uuid,v1 用于“创建版本 1 (时间戳) UUID”。但它并没有为我生成时间戳。
参考文件的截图:
为什么会这样?我是不是在错误地使用这个函数?
英文:
I have the following code:
const handlefb = async () => {
const fb = sRef(storage, `paramKey/${feedback + v1()}`);
uploadString(fb, todoDatafb).then((snapshot) => {
console.log('Uploaded new feedback')
})
According to https://www.npmjs.com/package/uuid, v1 is for Create a version 1 (timestamp) UUID
. But it does not generate a timestamp for me.
Refer to screenshot of the file:
How come? Am I using the function wrongly?
答案1
得分: 1
函数正常运行。它正在生成一个 UUID。v1 不生成时间戳,它生成基于时间的 UUID。如果您需要时间戳,只需使用 JavaScript 的 Date
对象。
英文:
The function is working as expected. It's generating a uuid. v1 does not generate a timestamp, it generates a time-based uuid. If you want a timestamp, just use the JavaScript Date
object.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论