草庐IT

prop_cycle

全部标签

javascript - react native : No propType for native prop RCTView. 最大高度

升级到RN0.30后,即使构建最简单的可能,我也开始看到下面显示的错误app:react-nativeinitAwesomeProjectreact-nativerun-ios最奇怪的是组件BlurView、VibrancyView和RNSearchBar包含在警告消息中,尽管项目没有使用它们。重新编译/清理项目并不能解决问题。控制台和错误:2016-07-2208:48:02.985[warn][tid:main][RCTEventEmitter.m:52]Sending`websocketFailed`withnolistenersregistered.2016-07-2208:4

javascript - 失败的形式 propType : You provided a `value` prop to a form field without an `onChange` handler

当我加载我的React应用程序时,我在控制台中收到此错误。Warning:FailedformpropType:YouprovidedavalueproptoaformfieldwithoutanonChangehandler.Thiswillrenderaread-onlyfield.IfthefieldshouldbemutableusedefaultValue.Otherwise,seteitheronChangeorreadOnly.ChecktherendermethodofAppFrame.我的AppFrame组件如下:classAppFrameextendsCompone

javascript - 警告 : Failed propType: Invalid prop `component` supplied to `Route`

我正在尝试新的react-router1.0.0,我收到了我无法解释的奇怪警告:Warning:FailedpropType:Invalidprop`component`suppliedto`Route`.Warning:Invalidundefined`component`suppliedto`Route`.应用很简单:importReactfrom'react';importReactDOMfrom'react-dom';import{Router,Route}from'react-router';importAppfrom'./components/app';varSpeaker

javascript - react : inline conditionally pass prop to component

我想知道是否有比使用if语句更好的有条件地传递prop的方法。例如,现在我有:varparent=React.createClass({propTypes:{editable:React.PropTypes.bool.isRequired,editableOpts:React.PropTypes.shape({...})},render:function(){if(this.props.editable){return();}else{//Inthiscase,ChildwillusetheeditableOptsfromitsowngetDefaultProps()return();

javascript - react-router 在子组件中获取 this.props.location

据我了解将给出App与路由相关的Prop,如location和params.如果我的App组件有许多嵌套的子组件,我如何让子组件访问这些Prop而不需要:从App传递props使用窗口对象为嵌套的子组件创建路由我以为this.context.router会有一些与路线相关的信息,但是this.context.router似乎只有一些操作路线的功能。 最佳答案 V6您可以使用useNavigate,useLocation和useMatch在您的组件中获取matchPath,navigate和location.constChild=()

javascript - 将 Prop 动态传递给 VueJS 中的动态组件

我有一个动态View:与关联的Vue实例:newVue({data:function(){return{currentComponent:'myComponent',}},}).$mount('#myview');这允许我动态更改我的组件。在我的例子中,我有三个不同的组件:myComponent、myComponent1和myComponent2。我像这样在它们之间切换:Vue.component('myComponent',{template:""}现在,我想将props传递给myComponent1。当我将组件类型更改为myComponent1时,如何传递这些props?

javascript - 在 Vue.js 2 中将 Prop 作为初始数据传递的正确方法是什么?

所以我想将props传递给Vue组件,但我希望这些props将来会从该组件内部发生变化,例如当我使用AJAX从内部更新该Vue组件时。因此它们仅用于组件的初始化。我的cars-listVue组件元素,我在其中将具有初始属性的Prop传递给single-car://cars-list.vueexportdefault{data:function(){return{cars:[{color:'red',maxSpeed:200,},{color:'blue',maxSpeed:195,},]}},}我现在的做法是,在我的single-car组件中,我将this.initialPropert

javascript - 什么是 {this.props.children} 以及何时应该使用它?

作为React世界的初学者,我想深入了解当我使用{this.props.children}时会发生什么,以及在什么情况下使用它。它在下面的代码片段中有什么相关性?render(){if(this.props.appLoaded){return({this.props.children});}} 最佳答案 Whatevenis‘children’?TheReactdocssaythatyoucanuseprops.childrenoncomponentsthatrepresent‘genericboxes’andthatdon’tkn

javascript - 为什么使用 Object.prototype.hasOwnProperty.call(myObj, prop) 而不是 myObj.hasOwnProperty(prop)?

如果我理解正确的话,JavaScript中的每个对象都继承自Object原型(prototype),这意味着JavaScript中的每个对象都可以通过其原型(prototype)链访问hasOwnProperty函数。阅读时RequireJS'源代码,我偶然发现了这个函数:functionhasProp(obj,prop){returnhasOwn.call(obj,prop);}hasOwn是对Object.prototype.hasOwnProperty的引用。将这个函数写成functionhasProp(obj,prop){returnobj.hasOwnProperty(pro

javascript - 为什么 JSX Prop 不应该使用箭头函数或绑定(bind)?

我正在用我的React应用程序运行lint,但我收到此错误:errorJSXpropsshouldnotusearrowfunctionsreact/jsx-no-bind这是我运行箭头函数的地方(在onClick内):{this.state.photos.map(tile=>(this.selectPicture(tile)}style={{position:'absolute',zIndex:99,padding:5,backgroundColor:'rgba(255,255,255,0.72)'}}/>by{tile.author}}actionIcon={this.handle