草庐IT

print_df_in_a_function

全部标签

javascript - Angular 1.5 组件 : passing a function

是否可以将函数传递给组件并在传递参数的组件内部调用此函数?例子:帖子列表getPostUrl是一个函数(在容器Controller中):constgetPostUrl=(postId)=>{constprotocol=$location.protocol();consthost=$location.host();constport=$location.port();returnprotocol+"://"+host+""+(port!==80?":"+port:"")+"/blog/post/"+postId;};帖子列表:组件constPostList={"bindings":{"p

javascript - 我所有的 Observables 错误 'takeUntil is not a function'

出于某种原因,我无法在我的任何可观察对象上使用takeUntil方法。我的IDE(VisualStudioCode)在我编码时将其显示为有效方法,并且编译良好(从typescript),但是当我运行它时,我得到takeUntilisnotafunction在我的任何observables上。我使用的是rxjs版本5.3.0。我可以通过多种方式实现它,但这可能是最直接的:letsubject:BehaviorSubject=newBehaviorSubject({});letunsubscribe:Subject=newSubject();subject.takeUntil(unsubs

javascript - 创建一个 jQuery 插件 : best practices regarding functions' visibility?

我正在创建一个jQuery插件。到目前为止它工作正常,但我对我做事的方式有疑问:jQuery.fn.myMethod=function(){returnthis.each(function(){MyScope.doSomething(jQuery(this).attr("id"));});};varMyScope={//ThefunctionscontainedinMyScopeareextremelylinkedtothelogic//ofthispluginanditwouldn'tmakealotofsensetoextractthemdoSomething:function(i

javascript - React JS 未捕获引用错误 : function not defined

我正在尝试在ReactJs组件中发生单击事件时调用shuffleCards。但是,我收到以下错误:UncaughtReferenceError:shuffleCardsisnotdefined这是我的代码:constructor(props){super(props);this.state={count:0};}shuffleCards(array){vari=array.length,j=0,temp;while(i--){j=Math.floor(Math.random()*(i+1));temp=array[i];array[i]=array[j];array[j]=temp;}

javascript - JS 日期 : Add 0 in front of every single day or month

我将此日期从api解析为字符串:DD-MM-YYYY但有时日期是DD-M-YYYY甚至D-M-YYYY。例如:2013年4月1日要么10-10-2013或7-4-2013年份始终为4位数,但日或月有时为一位数。如何手动(使用JS)在每个数字前添加0?我正在使用moment.js进行一些计算,因此我使用删除了“-”date.replace("-","")得到一个整数(例如4-1-2013=412013),这样我就可以将它与moment.js一起使用,但如果它是一个数字,一切都会变得一团糟。 最佳答案 您可以像这样首先规范化您的字符串:

javascript - JavaScript 中的 var thing 和 function thing() 有什么区别?

我只是想知道以下JavaScript对象声明之间的区别。具体来说,thingobjectliteral和thingclass中的thing1object之间的区别。代码:varthing={sanity:0,init:function(){//code},send:function(){//code}}functionthing(){this.sanity=0;this.init=function(){//code};this.send=function(){//code};}thing1=newthing(); 最佳答案 静态对象

javascript - appendChild 错误 : Node cannot be inserted at the specified point in the hierarchy

appendChild函数出错:无法在层次结构中的指定点插入节点JS:varabc=document.createElement("div");abc.style.position="absolute";abc.style.width="10px";abc.style.height="10px";abc.style.left="10px";abc.style.top="10px";abc.style.backgroundColor="black";abc.innerHTML="abc";document.appendChild(abc);http://jsfiddle.net/T7ZM

javascript - Javascript 中的 !function 是什么意思?

这个问题在这里已经有了答案:Whatdoestheexclamationmarkdobeforethefunction?(8个答案)关闭5年前。很抱歉发布这个,但是!function无法通过google搜索,而且我没有在我的JavaScript代码中找到它。Twitter是这样使用它的:Tweet!function(d,s,id){varjs,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/wi

javascript - 在 javascript 中正确使用 "for...in"循环?

在我提出问题之前,我想让每个人都知道,我很感激总有人愿意提供帮助这一事实,而在我这边,我会尽我所能回馈社区。谢谢现在,我想获得一些关于如何正确利用JavaScript中的“for...in”循环的指示,我已经做了一些研究并尝试了一些事情,但我仍然不清楚如何正确使用它。假设我在HTML表单中有随机数量的“选择”标签,我不要求用户为所有标签选择一个选项,如果他们愿意,他们可以保留一些不变。但是我需要知道他们是没有选择还是至少选择了一个。我试图找出用户是否选择了其中任何一个的方法是使用“for...in”循环。例如:varallSelected=$("selectoption:selecte

javascript - Uncaught Error : No Storage Bucket defined in Firebase Options.(网络)

我试图在firebase存储上上传文件(图像)。但它会显示一条错误消息“UncaughtError:Firebase选项中未定义存储桶。”.这是我的代码constfileUpBtn=document.getElementById('photoUpload');constselectFile=document.getElementById('selectedFile');constpostIt=document.getElementById('postIt');fileUpBtn.addEventListener('click',function(){selectFile.click()