小编fra*_*ran的帖子

React Native Flexbox中的100%宽度

我已经阅读了几个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)

flexbox react-native

184
推荐指数
6
解决办法
18万
查看次数

动态更改表单操作URL无效

当动态更改表单操作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)

谢谢.

javascript forms url action dynamic

4
推荐指数
1
解决办法
7063
查看次数

标签 统计

action ×1

dynamic ×1

flexbox ×1

forms ×1

javascript ×1

react-native ×1

url ×1