草庐IT

is_object

全部标签

javascript - jQuery & Objects,试图制作一个轻量级的小部件

尝试制作一个可以动态添加元素的通用选择“控件”,但我无法让函数正常工作。这就是我的出发点。$select=$("");$select.addOption=function(value,text){$(this).append($("").val(value).text(text));};这单独运行良好,但任何时候$select是.clone(true)时addOption()函数都会丢失。这是我的对象方法,但该功能仍然不起作用。function$selectX(){return$("");}$selectX.prototype.addOption()=function(value,te

javascript - Fabric JS : Copy/paste object on mouse down

我正在尝试创建一个方block游戏,您可以在其中从菜单中选择形状并将它们放置在Canvas上。有一个形状菜单,您可以在其中将形状拖到Canvas上。我希望它在将克隆拖到Canvas上时将主要形状留在菜单中。这可能吗?我创建了一个jsfiddle来提供帮助。JSFIDDLEwindow.canvas=newfabric.Canvas('fabriccanvas');varedgedetection=10;//pixelstosnapcanvas.selection=false;window.addEventListener('resize',resizeCanvas,false);fun

javascript - 安装 visual Studio 2015 社区版后,Crystal Reports 13 bobj is undefined JavaScript 错误

在带有CrystalReport13的VisualStudio2010中,我的项目运行良好。在我安装Visualstudio2015社区版之后供我个人使用。当我打开我的项目并在VisualStudio2010中运行时,它抛出“JavaScript运行时错误:‘bobj’未定义”。我浏览了一些网站http://www.mahadera.com/error-0x800a1391-javascript-runtime-error-bobj-is-undefined/http://www.aspsnippets.com/Articles/Crystal-Reports-13-Visual-St

javascript - Uncaught ReferenceError : Worker is not defined while trying to create a Worker within another Worker in Chrome

这link说:Workersmayspawnmoreworkersiftheywish.So-calledsub-workersmustbehostedwithinthesameoriginastheparentpage.Also,theURIsforsubworkersareresolvedrelativetotheparentworker'slocationratherthanthatoftheowningpage.Thismakesiteasierforworkerstokeeptrackofwheretheirdependenciesare.但是当我尝试在另一个Worker中创

javascript - Object3D 中的交集

我将一些对象添加到Object3D(用于对元素进行分组)并且我正在尝试检测对它的点击。我的场景大小为600x400,我的相机位于三对象内,我的事件处理程序代码如下所示:functiononDocumentMouseDown(event){event.preventDefault();varmouse={};mouse.x=(event.clientX/600)*2-1;mouse.y=-(event.clientY/400)*2+1;varvector=newTHREE.Vector3(mouse.x,mouse.y,1);projector.unprojectVector(vecto

javascript - 请求动画帧 : what exactly is the timestamp?

我一直认为requestAnimationFrame使用的时间戳和JavaScript中常用的时间戳是一样的,就是从1970年1月1日开始的毫秒数,今天抓取时间戳验证了一下,发现RAF时间戳大概是从1970年1月1日开始算起的页面加载的开始。时间戳的精确测量依据是什么?测试代码:vari=0;varstart=null;vartimes=[];vardur=5000;functionstep(timestamp){if(start===null)start=timestamp;times[i++]=timestamp;if(timestamp-start');}}requestAnim

javascript - 未捕获的类型错误 : lang is not a function

这个问题在这里已经有了答案:JSfunctionnamed`animate`doesn'tworkinChrome,butworksinIE(3个答案)关闭6年前。在我的HTML中,我在script标签中定义了lang函数并添加了“TestFire!”单击时必须调用lang的按钮:TestingFunctionsfunctionlang(){alert("Hello,World!It'sJavaScriptthistime");}但是,如果我点击按钮,我会得到这个错误:UncaughtTypeError:langisnotafunction但是,如果我将函数名称从lang更改为任何其他

javascript - 类型错误 : scrollIntoView is not a function

我是react-testing-library/jest的新手,正在尝试编写测试以查看路由导航(使用react-router-dom)是否正确执行。到目前为止,我一直在关注README还有这个tutorial关于如何使用。我的一个组件在本地函数中使用了scrollIntoView,这导致测试失败。TypeError:this.messagesEnd.scrollIntoViewisnotafunction45|46|scrollToBottom=()=>{>47|this.messagesEnd.scrollIntoView({behavior:"smooth"});|^48|}49|

javascript - Mongoose : Inserting JS object directly into db

好的,我有一个通过AJAX发布到nodejs后端的JS对象。我想将这个js对象直接插入到我的Mongoose数据库中,因为对象键已经与数据库模式完美匹配。我目前有这个(不是动态的并且过于复杂):app.post('/items/submit/new-item',function(req,res){varformContents=req.body.formContents,itemModel=db.model('item'),newitem=newitemModel();newitem.item_ID="";newitem.item_title=formContents.item_tit

javascript - 在 Javascript 中为 Object 定义一个原型(prototype)函数可以吗?

这个问题在这里已经有了答案:HowtodefinemethodinjavascriptonArray.prototypeandObject.prototypesothatitdoesn'tappearinforinloop(4个答案)关闭3年前。Object.prototype.doSomething=function(p){this.innerHTML="bar";this.style.color="#f00";alert(p);};document.getElementById("foo").doSomething("HelloWorld");foo上面的代码工作正常。但我记得我在