我对node.js完全不熟悉.我有两个我想运行的node.js脚本.我知道我可以单独运行它们但我想创建一个运行这两个脚本的node.js脚本.应该是主node.js脚本的代码?
我在 Vercel 上托管了一个盖茨比博客。对于我的主页,我从 Mongo Atlas 获取动态内容。
我正在盖茨比中创建动态路线
createPage({
path: '/microblog/:id',
matchPath: '/microblog/:id',
component: path.resolve(`./src/pages/index.jsx`),
});
Run Code Online (Sandbox Code Playgroud)
当我在本地请求/microblog/5f3114b3e096870008336d7c(现在使用 vercel 运行)时,它可以工作,但在产品上,您可以看到它重定向到 404 (https://sagark.dev/microblog/5f3114b3e096870008336d7c)
另外,如果网站已完全呈现。该链接有效。我认为问题与 Vercel 动态路由有关,或者我遗漏了一些东西。
我正在制作一种游戏,我希望用户输入一个特定的单词,然后我想检查是否按下了特定的单词.如果单词被按下,我将获取下一个单词.目前我正在使用表单并使用了如下所示的v-model:
<input v-model="inputSpell">
Run Code Online (Sandbox Code Playgroud)
在Vue实例中,我使用了watch属性,该属性不断检查输入的单词是否与被询问的单词匹配.
watch : {
inputSpell : function() {
var spellCount = this.spellCount;
var inputSpell = this.inputSpell.toUpperCase();
var presentSpell = this.presentSpell;
console.log("Spell Count " + spellCount);
console.log("Input Spell " + inputSpell);
console.log("Present Spell" + presentSpell);
if (inputSpell.length === 3 && inputSpell === presentSpell) {
this.$set(this, 'inputSpell', '');
if (spellCount === 3) {
return this.completeCombo();
}
return this.fetchSpell(spellCount);
}
if (inputSpell.length >=3) {
this.$set(this, 'inputSpell', '');
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想到了三个想法:
上面我正在做的是显示表格.用户输入该表单中的单词.看起来不太好看.
在加载游戏时,使输入元素隐藏并专注于它.但缺点是如果用户点击页面上的任何地方,表单上的焦点将会丢失.
制作自定义指令或调用捕获按键事件以检查单词的方法.
任何帮助将不胜感激.
谢谢.
我的 mongo 集合中有超过 1000 万条记录,我想将它们移动到其他数据库。
有两种方法可以实现这一目标:
使用 find 批量数据
const batchSize = 1000;
const collection = mongo.client.collection('test');
const count = await quizVersionCollection.count();
let iter = 0;
while (iter * batchSize <= count) {
const dataArr = await collection.find({})
.sort({ _id: -1 })
.limit(batchSize)
.skip(iter * batchSize)
.toArray();
iter += 1;
}
Run Code Online (Sandbox Code Playgroud)
使用 mongo 游标
while (yield cursor.hasNext()) {
const ids = [];
const batchSize = 1000;
for (let i = 0; i < batchSize; i += 1) {
if (yield …Run Code Online (Sandbox Code Playgroud)