我已经阅读了几个flexbox教程,但我仍然无法使这个简单的任务工作.
如何将红色框设为100%宽度?
码:
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Natives
</Text>
<Text style={styles.line1}>
line1
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
样式:
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
borderWidth: 1,
flexDirection: 'column',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
borderWidth: 1,
},
line1: {
backgroundColor: '#FDD7E4',
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
borderWidth: 1,
},
Run Code Online (Sandbox Code Playgroud)
谢谢!
更新1: Nishanth Shankar的建议,为包装器添加flex:1,flexDirection:'row'
输出:
码:
<View …Run Code Online (Sandbox Code Playgroud) 当动态更改表单操作URL时,当表单提交时,它仍将使用默认操作URL,任何人都知道为什么?请看下面的一个简单示例:
<form action="test.php" method="get" id="test">
<select name="id" onChange="formSubmit(this)">
<option value="abc">abc</option>
<option value="xyz">xyz</option>
</select>
</form>
<script type="text/javascript">
function formSubmit(element){
var url = $("#test").attr("action", url);
var newParam = "&new=123";
url += "?" + element.name + "=" + element.value + newParam;
//e.g. formurl now = 'test.php?id=xyz&new=123';
$("#test").attr("action", url);
$("#test").submit();//the form will submit to test.php?id=xyz instead of the new URL
}
</script>
Run Code Online (Sandbox Code Playgroud)
谢谢.