草庐IT

functions-for-testing-spatial-rel

全部标签

javascript - Firebase Function 从其他文件导入函数 - javascript

我正在使用javascript构建firebase函数。现在我有很多内部调用函数,我打算将这些函数移动到不同的文件中,以避免index.js变得非常困惑。下面是当前的文件结构:/functions|--index.js|--internalFunctions.js|--package.json|--package-lock.json|--.eslintrc.json我想知道:1)如何从internalFunctions.js中导出函数并将其导入到index.js中。2)如何从index.js调用internalFunctions.js函数。我的代码是用JavaScript编写的。已编辑

javascript - 错误信息。 "Props with type Object/Array must use a factory function to return the default value."

我正在使用Vue-Cli3.0。我将此模块用于Vue.js。https://github.com/holiber/sl-vue-tree这是一个可自定义的可拖拽的Vue.js树组件,但我发现它无法复制对象的功能。https://github.com/holiber/sl-vue-tree/blob/master/src/sl-vue-tree.js#L715因为这里。JSON.parse(JSON.stringify(entity))所以我使用了这个模块并编辑了复制功能。https://www.npmjs.com/package/clonevarclone=require('clone

javascript - 调用 Function.prototype.method() 时 TypeError : this. prototype is undefined

我正在读《Javascript:好的部分》这本书。现在我正在阅读有关增强类型的章节:Function.prototype.method=function(name,func){this.prototype[name]=func;returnthis;};更新:为什么下面的代码不起作用?js>Function.prototype.method("test",function(){print("TEST")});typein:2:TypeError:this.prototypeisundefined但是下面的代码没有问题:js>Function.method("test",function

javascript - 在 for 循环中使用现有变量

是否可以从for循环中省略变量赋值并执行类似这样的操作......?otherVar=3;for(otherVar>0;otherVar--){stuff} 最佳答案 是的,但你需要输入分号:varotherVar=3;for(;otherVar>0;otherVar--){doStuff();} 关于javascript-在for循环中使用现有变量,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/q

javascript - 使用 `new Function` 和性能问题

我正在通过AJAX加载一个脚本文件,并运行它的内容,我正在这样做:newFunction('someargument',xhr.responseText)(somevalue);但是,根据MDN:FunctionobjectscreatedwiththeFunctionconstructorareparsedwhenthefunctioniscreated.Thisislessefficientthandeclaringafunctionandcallingitwithinyourcode,becausefunctionsdeclaredwiththefunctionstatement

javascript - 使用空主体 for-in 循环将对象属性复制到数组

`我正在阅读“JavaScript:权威指南”,我被一个例子迷住了:“您可以使用如下代码将所有对象属性的名称复制到一个数组中”varo={x:1,y:2,z:3};vara=[],i=0;for(a[i++]ino)/*empty*/;我不明白,为什么最后一行在没有说明的情况下真的做了任何事情。为什么会填满数组? 最佳答案 这是有效的,因为for循环将o中的值分配给in左侧的变量。通常这是用于某些函数的新变量。例如for(varaino){/*用*做一些事情在这种情况下,它将它分配给a[i++]其中i++每次增加1还值得指出;inf

javascript - Mongoose - TypeError : object is not a function

我正在尝试将Mongoose模型从我的model/user.model.js文件导出到我的服务器目录中的server.js文件。模型/user.model.jsvarmongoose=require('mongoose');varSchema=mongoose.Schema();varUserSchema=newSchema({instagramId:{type:String,index:true},email:{type:String,unique:true,lowercase:true},password:{type:String,select:false},userName:St

javascript - for 循环中的 Promise 链

for(variinlistofInstances){cleanupInstance(listofInstances[i]).then(function(){console.log("Done"+listofInstances[i])});}cleanupInstance也是一个promise链。然而,目前我的for循环在整个promise链完成之前进入下一次迭代。有没有办法也promise循环?我正在使用Bluebird库(nodejs)来实现promise。 最佳答案 你可以使用.each:varPromise=require(

javascript - 仅在 Chrome 中(服务 worker ): '... a redirected response was used for a request whose redirect mode is not "follow"'

当我在Chrome中刷新(或离线)时,我得到“无法访问此站点”并且以下内容记录到控制台:TheFetchEventfor"http://localhost:8111/survey/174/deployment/193/answer/offline/attendee/240/”导致网络错误响应:重定向响应用于重定向模式不是“跟随”的请求。。当我在Firefox中刷新时,一切正常。有人可以解释为什么会这样吗?这是我简化的软件。importScripts("/static/js/libs/idb.js")varCACHE_NAME="upshot-cache-version3"varurls

javascript - 是否有类似于 HTML Tidy for Javascript 的 Windows 实用程序?

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭7年前。Improvethisquestion我想清理一些javascript文件并用漂亮的缩进等重新格式化它们,是否有实用程序在Windows下执行此操作的建议?