草庐IT

some_props

全部标签

javascript:使用单位获取css prop值

这个问题在这里已经有了答案:GetelementCSSproperty(width/height)valueasitwasset(inpercent/em/px/etc)(5个答案)关闭6年前。我的代码是这样的:#image_1{position:absolute;top:3vw;}我的尝试:http://jsfiddle.net/z8k6t3fb/1/我想要'3vw'这可能吗?

javascript - 将 Prop 从 child 传递给 parent react 导航

我正在使用react-navigation。我正在将props从react-nativecomponent传递到react-navigation的modal,它在点击。exportdefaultclassSomeCompextendsComponent{...render(){const{navigate}=this.props;return()}}在modal中,我访问了关闭modal的goBack()函数,以及props通过SomeComp传递exportdefaultclassModalextendsComponent{...render(){const{data,...}=th

javascript - 如何指定 proptypes 以允许可为空的、必需的 prop 值?

对于我的项目,希望在组件属性中传递null值以指示未指定的值(“已知未知”,如果您愿意的话)。以这种方式使用null是我们团队的惯例。通过组件propTypes定义,我想要求为prop传递一个值,但允许它为null(不是未定义),而Reactprop类型验证不会触发警告。所以以i/o风格重申一下:propvalue=string/number/object/etc-->无警告propvalue=null-->无警告propvalue=undefined(显式或仅省略prop值分配)-->warning如何实现这种行为?一个想法是写一些替代.isRequired的东西,比如.isDefi

javascript - react 中的 props.children 不能是无状态组件?

我正在尝试在React中练习渲染Prop模式,但出现了错误this.props.childrenisnotafunction这是我的代码importReactfrom'react';import{render}from'react-dom';constBox=({color})=>(thisisbox,withcolorof{color});classColoredBoxextendsReact.Component{state={color:'red'}getState(){return{color:this.state.color}}render(){returnthis.props

javascript - 在 PyCharm 中禁用 React Prop 的自动 {} 插入

当我在PyCharm的React组件中输入props时,它会自动插入一对大括号。像这样(光标位置是|):变成:我搜索了所有设置,但没有找到相关设置来禁用它。存在吗? 最佳答案 您可以通过关闭来禁用大括号自动插入“在键入‘=’和属性完成时为属性值添加引号”在Settings->Editor->General->SmartKeys但这将禁用自动插入HTML的引号。 关于javascript-在PyCharm中禁用ReactProp的自动{}插入,我们在StackOverflow上找到一个类似

javascript - 将 Prop 传递给动态 TabNavigator

(也在https://github.com/react-navigation/react-navigation/issues/4059#issuecomment-453100740中询问)我用动态TabNavigator替换了静态TabNavigator,一切正常。然而,已经按预期传递的props不再以相同的方式传递。知道如何解决这个问题吗?要么像在静态解决方案中那样传递props,要么传递所需的props(this.props.navigation)。这是我的顶级导航器:exportdefaultcreateDrawerNavigator({Drawer:MainDrawerNavi

javascript - arguments 属性可以通过 this.some_function.arguments 访问吗?其实我无法解释?

我在读一本JavaScript书,我在读如何通过原型(prototype)扩展JavaScript数组的数组功能,然后我来到这个我无法理解的例子,也没有对它进行深入的解释,我不是能够理解:Array.prototype.some_function=function(){varargs=this.some_function.arguments;//1varargs_length=this.some_function.arguments.length;//2...}//some_function在这里我能够访问参数,但我不知道这是如何工作的,意思是this指的是我们调用此方法的对象(在此上

javascript - 通过 Props 将值从 React Stateless Child 传递给 Parent

语境我正在尝试将输入值字段(conditionTitle)从ReactStateless子组件(AddConditionSelect)传递到父组件(AddConditionDashboard)>)这将保持我的状态。问题我遵循了Reactdocumentation中显示的模型,但他们使用的是refs,这仅在组件是有状态的情况下才有效。我不想在子组件中设置任何状态,但仍然能够访问父组件中的输入。在目前的形式中,我收到一个警告,无状态函数组件不能被赋予refs,导致props为null和未定义。父组件:importAddConditionSelectfrom'../containers/Ad

javascript - 我什么时候需要使用 super(props) 将 prop 传递给 React 组件的构造函数?

这个问题在这里已经有了答案:What'sthedifferencebetween"super()"and"super(props)"inReactwhenusinges6classes?(10个答案)关闭6年前。很多时候我们在构造函数中发送props但我们从来没有在构造函数中的任何地方使用this.props那么为什么需要传递它以及何时需要这样做。classAppextendsReact.Component{constructor(props){super(props);//Whendoweneedtosendpropstotheconstructorthis.state={data:

javascript - react 。 child 作为 Prop

我知道如何将child传递给React组件:OpenThisWonderfulLink但是我可以这样使用吗:有效,但这正常吗?我可以每次都使用这种方式吗?附言抱歉我的英语不好..) 最佳答案 是的,children就像任何其他prop一样,可以用作prop来渲染子组件,而不是将子组件嵌套在相应的元素 关于javascript-react。child作为Prop,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.