我想知道如何在发布问题时实现类似堆栈溢出的内容:"至少有一个标签,如(css html asp.net),最多5个标签.
我怎样才能在html中为文本输入实现这样的内容,它会部分褪色,但是当你键入时,它不会显示,也不会褪色.
我不介意怎么做,只要它有效.
谢谢.
我有一个scrollView包含太多的textInput。一切正常,直到我添加textAlign: 'right'到TextInput样式。之后,ScrollView无法响应滚动。这个问题只是在android中发生的,在iOS中按预期工作。我在Snake.expo中添加了一个简单的代码
render() {
let TextInput2 = (
<TextInput
style={{
flex: 1,
textAlign: 'right',
height: 50
}}
placeholder="placeholder"
/>
);
return (
<ScrollView>
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
{TextInput2}
</ScrollView>
);
}
Run Code Online (Sandbox Code Playgroud) 我有 TextInput 组件,每当用户键入时它都会更改状态,但我意识到由于 TextInput 的值使用 this.state.text 作为值,双击空格不会在 iO 上产生句点。
是否有解决办法,以便双击空间仍然可以在 ios 上产生句点?
onChange =(text) => {
this.setState({text});
}
<TextInput
onChangeText={this.onChange}
onSubmitEditing={this.onSubmit}
value={this.state.text}
autoCapitalize="sentences"
blurOnSubmit={false}
editable={true}
/>
Run Code Online (Sandbox Code Playgroud) 所以我用我的状态来控制文本输入,但是当我输入一个字符时,我不希望该字符立即显示。正在发生的事情是这样的: 1. 我专注于文本输入 2. 我输入一个字符。3. 字符快速显示在文本输入中。4. 字符很快消失,并且值恢复到状态,因为状态还没有改变。
我想知道如果状态没有改变,我如何才能阻止角色出现。
这是一个简单的例子:
state = {
myValue: 'hello'
}
changedText = value => {
//Nothing here yet
}
...
render(){
return(
<Input
value={this.state.myValue}
keyboardType="numeric"
onChangeText={this.highIntervalDurationChange}
/>
);
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这并不复杂,我只是想找出一种方法,使按下的字符在按下时不会立即出现,因为当前它出现并恢复到状态。(显然,在我弄清楚如何防止默认情况发生后,我将修改状态。)我还尝试将 editable 设置为 false,这使得我根本无法编辑它。谢谢!
我有一个 TextInput 组件,可以在打字时将输入转换为大写字母。我的代码如下:
import React, {Component} from 'react';
import { View, StyleSheet, Text, TextInput, Button } from 'react-native';
export default class ProfileTest extends React.Component {
constructor(props) {
super(props);
this.state = {text : ''};
}
render() {
return (
<View>
<TextInput
style={{fontSize : 60}}
onChangeText={text => {
text = text
.toUpperCase();
this.setState({ text: text });
}}
value={this.state.text}
placeholder="enter text"
/>
</View>
)
}
}
Run Code Online (Sandbox Code Playgroud)
在世博会上,这确实有效。但是,当我在 Android 设备上尝试此操作时,我得到以下行为:

前两个字母工作正常,但每当我添加第三个字母时,它就会突然重复前两个字母,这样 ABC -> ABABC 我不知道为什么它会这样做,而且我似乎无法摆脱它。我已确定“.toUpperCase()”是罪魁祸首。
感谢您的帮助!
我想构建一个多行 TextInput 聊天应用程序,用户可以在按下 Enter 时发送消息。然而,似乎当用户按下 Enter 时,无论如何都会插入新行,这给用户带来了不好的体验。
我已经尝试过如何在react-native中按下回车键时防止换行,但在用户按键盘中的Enter键后,新行仍然存在。我还尝试在触发时修剪文本onChangeText,但似乎新行仍然插入。我知道它在 时有效blurOnSubmit=true,但我想在用户按 Enter 时保持键盘打开。
maxLength我在 ReactNative中遇到了一个问题<TextInput/>,我很确定它只发生在 iOS 上。
问题:
如果输入的最后一个字符是表情符号,并且该表情符号将您置于maxlength数字上,那么它将删除整个输入!例如,如果maxLength设置为 5 并且输入为“xxxx”(4 个字符),然后添加表情符号,则整个输入文本将被删除。我确信这与表情符号主要是 2 个字符有关,但我似乎找不到“雄辩”的解决方法!
小吃一下,看看我在说什么:
(我只能在 iOS 中复制它) https://snack.expo.io/@sararan/textinput
我尝试过的事情:
onKeyPress事件(在该事件之前被击中onChangeText)(都是为了更好的措施;))。但它实际上并没有停止事件,我认为这与反应如何处理事件有关,也许这个时候它已经冒泡了?e.stopPropagation()e.preventDefault()完全取出maxLength并创建我自己的规则,如果输入超过我想要的长度,则拼接输入,然后替换任何特殊字符,例如......
const onChangeText = (value) => {
if (value.length > 5) {
value = value.slice(0, 30).replace(/[^\w\s]/gi, '');
}
setText({ value });
};
Run Code Online (Sandbox Code Playgroud)
但这种解决方案似乎会导致我们都讨厌这些类型的解决方案的闪烁。
我想知道是否有人以前遇到过这个问题并且可能有更雄辩的解决方案?感谢您的帮助!
我在 React Native 中设置 TextInput 块样式时遇到问题
我的目标是具有相同模糊效果背景+模糊的输入
现在我的代码是:
<View style={styles.controll}>
<View style={styles.inputWrapper}>
<BlurView intensity={10}>
<TextInput style={styles.emailInput} />
</BlurView>
</View>
<View style={styles.inputWrapper}>
<BlurView intensity={10}>
<TextInput style={styles.passInput} />
</BlurView>
</View>
</View>
Run Code Online (Sandbox Code Playgroud)
我正在使用 Expo 组件 BlurView import { BlurView } from "expo-blur";
设计代码是
background: rgba(20, 15, 38, 0.648579);
backdrop-filter: blur(44.119px);
border-radius: 20px
Run Code Online (Sandbox Code Playgroud)
我的风格看起来像:
const styles = StyleSheet.create({
inputWrapper: {
width: "100%",
height: 75,
backgroundColor: "rgba(20, 15, 38, 0.648579)",
filter: "blur(44.119)",
borderRadius: 20,
position: "relative",
overflow: "hidden",
marginBottom: 25
},
emailInput: {
height: "100%", …Run Code Online (Sandbox Code Playgroud) 我想在初始状态(不是 onFocus)调整概述的react-native-paper TextInput 标签颜色。这是我的 OutlinedInput 组件:
import * as React from 'react';
import { TextInput } from 'react-native-paper';
const OutlinedInput = (props) => {
return (
<TextInput
mode='outlined'
label={props.label}
placeholder={props.placeholder}
placeholderTextColor='white'
secureTextEntry={props.secureTextEntry}
multiline={props.multiline}
keyboardType={props.keyboardType}
value={props.value}
onChangeText={(value) => props.onChangeText(value)}
style={props.style}
theme={props.theme}
/>
);
};
export default OutlinedInput;
Run Code Online (Sandbox Code Playgroud)
在我的 Register 组件中,我在其中创建了一个 OutlinedInput 组件:
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
<OutlinedInput
label={'User Name'}
value={userName}
onChangeText={(userName) => setUserName(userName)}
style={{ color: 'white', backgroundColor: 'rgb(35,39,42)',
borderRadius: 5, width: '75%', height: '5%'
}}
theme={{ colors: { …Run Code Online (Sandbox Code Playgroud) 我是 React Native 的新手。文本输入中的文本在 Android 和 iOS 上看起来不同。如何在文本输入中垂直对齐文本?
我的代码:
import React from "react"
import { TextInput } from "react-native"
export default function Signup() {
return (
<TextInput
style={{ backgroundColor: 'red', height: 30, textAlignVertical: 'top' }}
/>
)
}Run Code Online (Sandbox Code Playgroud)
图片: