这是我的组件A:
const GenericTextInput = (props) => {
return (
<TextInput
style={styles.input}
{...props}
/>
);
};
Run Code Online (Sandbox Code Playgroud)
这是我的组件B:
const SignIn = (props) => {
return (
<View>
<GenericTextInput
placeholder="Email"
autoFocus={true}
keyboardType="email-address"
returnKeyType="next"
autoCorrect={false}
placeholderTextColor='rgba(250,248,244, .4)'
underlineColorAndroid='rgba(250,248,244, .7)'
/>
<GenericTextInput
placeholder="Password"
placeholderTextColor='rgba(250,248,244, .4)'
underlineColorAndroid='rgba(250,248,244, .7)'
secureTextEntry={true}
/>
</View>
);
};
Run Code Online (Sandbox Code Playgroud)
我想GenericTextInput在我的组件B中为第二个添加特定样式.在组件A中我想使用spread operator(它非常方便).
如果我只是做:
//component A
const GenericTextInput = (props) => {
return (
<TextInput
style={[styles.input, props.styles]}
{...props}
/>
);
};
//component B
const …Run Code Online (Sandbox Code Playgroud) 无法理解为什么<img>内部从顶部向下<div style="display: inline-block">推div?
HTML
<div id="wrapper">
<div id="a1">
<img src='...' alt=""/>
</div>
<div id="a2">
</div>
<div id="a3">
</div>
<div id="a4">
</div>
<div id="a5">
</div>
<div id="a6">
</div>
<div id="a7">
</div>
<div id="a8">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
div > div {
background: red;
height: 200px;
width: 19%;
text-align: center;
margin: 0 5% 5% 0;
display: inline-block;
}
img {
height: 128px;
width: 128px;
display: /* "BLOCK" FIXES THE ISSUE */;
}
Run Code Online (Sandbox Code Playgroud)
编辑
设置img以display: …
不知道为什么,但Animated没有属性subtract(例如。Animated.subtract(a,b)我怎样才能减去两个Animated.Values?
我有这个对象:
const Foo = {
bar(x) {
},
baz(x) {
},
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能重写这个对象,以便能够像这样调用它的方法:
Foo.bar(x).baz(y);
Run Code Online (Sandbox Code Playgroud)
而不是像这样调用它们:
Foo.bar(x);
Foo.baz(y);
Run Code Online (Sandbox Code Playgroud)
就像jQuery你可以在哪里调用一个接一个的功能......
$('bac').addClass('x').removeClass('y');
有谁能解释我..
为什么baz没有a宣布哪个var没有成为全球variable?
const foo = {
bar(baz) {
if (!baz)
baz = 1;
}
}
Run Code Online (Sandbox Code Playgroud)