草庐IT

firebase-cloud-functions

全部标签

javascript - 刷新后如何让用户登录到 firebase 应用程序?

我有一个内置firebase和angular的应用程序,我希望能够在刷新页面后让用户保持登录状态。现在我有一个登录屏幕,其中有两个绑定(bind)到Controller的基本输入字段this.email="";this.pass="";this.emessage="";this.loginUser=function(){ref.authWithPassword({email:this.email,password:this.pass},function(error,authData){if(error){console.log("LoginFailed!",error);this.em

javascript - Javascript:Function和Class有什么区别

随着2015年6月ECMAScript6的发布,引入了Javascript类语法。这个语法:classPolygon{constructor(width,height){this.width=width;this.height=height;}}基本上与:functionPolygon(width,height){this.width=width;this.height=height;}那么,使用类而不是传统函数有什么好处?在什么情况下我应该使用类而不是函数? 最佳答案 类和函数之间有一些区别-大多数人会从说类是“只是语法糖”开始,

javascript - function.apply.bind 在以下代码中如何工作?

所以我得到一个[200,599]的数组从promise返回并且spread内的回调函数被传递到Function.apply.bind,但现在我迷路了。[200,599]的数组如何拆分为x和y?apply.bind究竟是如何工作的?functiongetY(x){returnnewPromise(function(resolve,reject){setTimeout(function(){resolve((3*x)-1);},100);});}functionfoo(bar,baz){varx=bar*baz;//returnbothpromisesreturn[Promise.reso

javascript - Chrome 扩展 js : Sharing functions between background. js 和 popup.js

假设我有一个JavaScript函数foo(),我想在后台和popup.html中执行它。例如:它每小时在我的Chrome扩展程序的后台执行一次,但也可以由用户通过单击按钮从弹出菜单(popup.html)激活。我目前有一个定义foo()的global.js脚本,当我在我的中包含对foo()的调用时>popup.js文件,它们可以毫无问题地执行。(如果我在popup.html中包含这两个脚本)但是,当我尝试访问background.js中的foo()时,调用不会执行(即使global.js包含在“后台”“manifest.json”扩展文件中:"background":{"persis

javascript - firebase.initializeApp 回调/ promise ?

这是我的网页CalcoloDiliuzioniMyapp//InitializeFirebasevarconfig={apiKey:"",authDomain:"",databaseURL:"",storageBucket:"",};firebase.initializeApp(config);varuser=firebase.auth().currentUser;if(user){console.log(user);}else{console.log(user);}假设我有一个已经登录的用户。当我在控制台中加载页面时,我得到了null。虽然我期望拥有当前用户的对象。如果我在浏览器控制

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 - 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(); 最佳答案 静态对象