草庐IT

named_children

全部标签

javascript - 是否可以实现 'Continue as {Facebook user name}' 按钮?

我正在尝试为我的站点实现Facebook登录按钮。一些Facebook产品有一个很好的FB按钮,它使用已经登录的用户的Facebook用户名。还有一个问题:当用户已经在浏览器中登录时,是否可以使用Javascript获取FB名称?例子: 最佳答案 您可以在Facebook文档中找到它,登录按钮/插件配置器部分:https://developers.facebook.com/docs/facebook-login/web/login-button有一个选项:当用户登录Facebook时包括姓名和头像

javascript - typescript 错误 : Reserved word 'this' used as name

我正在尝试获取thisNode.jsTypeScript定义可以正常工作,但WebStorm给了我一大堆错误,其中包含所有相同的消息:Reservedword'this'usedasname.ThisinspectionreportsonanyusesofJavaScriptreservedwordsbeingusedasaname.TheJavaScriptspecificationreservesanumberofwordswhicharecurrentlynotusedasJavaScriptkeywords.Usingthosewordsasidentifiersmayresu

javascript - 使用 react-router-redux 时未定义 this.props.children

我遵循了githubpage上的react-router-redux示例,但是当我尝试通过{this.props.children}到IndexRoute我尝试记录它,它是未定义的。我通过控制台得到的唯一错误是Warning:Youshouldnotuseandinthesameroute;willbeignored,通过谷歌搜索这个错误,它只是人们说忽略它的那些错误之一,因为它不影响任何代码(出于某种原因)。package.json...."react":"^0.14.7","react-redux":"^4.4.0","react-router":"^4.0.0","react-r

javascript - 如何在 this.props.children 中访问 React 对象的类名

在this.props.children中有一些子组件的React组件渲染方法中。如何获取每个child的组件(类)名称以区分它们?React.Children.map(this.props.children,function(child){//howcanIgettheclassnameofachildorsomeotheridentifier}) 最佳答案 警告:如果使用缩小,这将无法在生产中使用在ES6中,每个函数的名称都存储在属性function.name中所以你可以用importReactfrom'react'...get

javascript - Svelte 等同于 React 的 props.children?

我在svelte3的任何地方都找不到这个功能。我希望它是这样的..App.svelteCan'tconnecttotheserver!`Error.svelte{props.children}我希望App.svelte显示:Can'tconnecttotheserver!我只知道如何使用React的props.children来做到这一点。 最佳答案 您可以使用slot.它是svelte提供的一个组件。您可以在您的组件中使用它。传递给组件的任何内容都将代替插槽呈现在你的error.svelte中试试这个

javascript - react : How to access refs in this. props.children

我想调用一个子组件的函数。是否有可能在React中从this.props.children获取引用。varComponentSection=React.createClass({componentDidMount:function(){//Howtoaccessrefsinthis.props.children?this.refs.inner.refs.specificPanel.resize();},render:function(){return({this.props.children});}});varPanel=React.createClass({resize:functi

javascript - 无法分配给对象 'name' 的只读属性 '[object Object]'

以下代码只会为name属性抛出错误。它可以通过在Object.create参数中将name属性指定为可写来修复,但是我试图理解为什么会这样(也许有一种更优雅的方法来修复它)。varBaseClass=function(data){Object.assign(this,data);}varExtendedClass=function(){BaseClass.apply(this,arguments);}ExtendedClass.prototype=Object.create(BaseClass);console.log(newExtendedClass({type:'foo'}));n

javascript - react : Why is `this.props.children` undefined?

我正在使用ReactJS构建电子电阻计算器。我有一个这样声明的组合组件:varResistanceCalculator=React.createClass({getInitialState:function(){return{bands:[0,0,0,0,0]}},componentDidMount:function(){console.log(this.props.children);//=>undefined},render:function(){return();}});BandSelector呈现元素和当一个改变时我想更新ResistanceCalculator的状态。所以我的

javascript - ReactJS - React.Children.forEach - 我可以获得子组件名称吗?

我有一个包含许多子项的React(15.5.4)组件,其中一些是HTML元素,一些是其他React组件。我正在使用服务器渲染并且需要在服务器和客户端上有相同的行为。客户端将使用React的生产构建。我需要遍历子组件并确定特定类型的React组件。所以我的第一个想法是使用React.Children.forEach()进行迭代并查找组件名称。React.Children.forEach(this.props.children,child=>{console.log('name=',child.name)})似乎child.name和child.displayName不存在。现在,chil

javascript - 在 Chrome 中工作,但在 Safari 中中断 : Invalid regular expression: invalid group specifier name/(? <=\/)([^#]+)(?=#*)/

在我的Javascript代码中,这个正则表达式/(?在Chrome中工作正常,但在safari中,我得到:Invalidregularexpression:invalidgroupspecifiername有什么想法吗? 最佳答案 看起来像Safaridoesn'tsupportlookbehindyet(即您的(?)。一种替代方法是将/在非捕获组之前出现的,然后仅提取第一组(/之后和#之前的内容)。/(?:\/)([^#]+)(?=#*)/此外,(?=#*)很奇怪-你可能想要向前看某些东西(例如#或字符串的末尾),而不是*量词(