javascript - 单击另一个可触摸不透明度并将其中的文本设置为文本输入中输入的值时,如何制作可触摸不透明度
问题描述
我是一个 13 岁的初学者反应原生,我需要帮助解决标题中的问题。
我需要通过可触摸的不透明度点击来完成这一切。我曾尝试在谷歌上搜索其他解决方案,但一无所获。
其实就是一个教程Youtube
。
这是链接:教程
请帮我。
谢谢你。
import React, { useState } from 'react';
import { StyleSheet, Text, View, FlatList, TextInput, TouchableOpacity } from 'react-native';
import Header from './components/header';
import TodoItem from './components/todoItem';
export default function App() {
const [todos, setTodos] = useState([
{ text: 'turn on laptop', key: '1'},
{ text: 'create an app', key: '2'},
{ text: 'play on the switch', key: '3'}
]);
const addToDo = () => {
}
const PressHandler = (key) => {
setTodos((prevTodos) => {
return prevTodos.filter(todo => todo.key != key);
});
}
return (
<View style={styles.container}>
<Header />
<View style={styles.content}>
{/* todo form */}
<View style={styles.list}>
<FlatList
data={todos}
renderItem={({ item }) => (
<TodoItem item={item} PressHandler={PressHandler}/>
)}
/>
</View>
</View>
<TextInput style={styles.todoInput} maxLength={20} onChange={() => this.setState} />
<TouchableOpacity style={styles.submitTodo} onPress={addToDo}>
<Text style={styles.submitTodoText}>Done</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
content: {
padding: 40,
},
todoInput: {
position: "absolute",
bottom: 1,
},
todoInput: {
height: 31,
borderColor: "coral",
borderStyle: "dashed",
borderWidth: 1,
borderRadius: 10,
position: "absolute",
bottom: 26,
width: "73%",
textAlign: "center",
marginLeft: 25,
},
submitTodo: {
padding: 10,
width: "15%",
position: "absolute",
right: 15,
bottom: 26,
backgroundColor: "coral",
borderRadius: 10,
alignItems: "center",
},
submitTodoText: {
color: "#fff",
fontSize: 10,
}
});
再次感谢您花时间在这上面。
解决方案
推荐阅读
- nuget - 将 NuGet 包发布到本地 Apache 服务器
- javascript - 如何使用 javascript 使 div 中的文本居中
- amazon-redshift - pg_terminate_backend - 如何让非超级用户执行它?
- c# - DLL 中的进度条
- android - 无法使用 OpenCV 检测人脸
- reactjs - script1010:未识别的语法 | 无法使用 Babel for IE11 将 ES6 转换为 ES5
- mysql - 将所有带前缀的表合并为一个
- python - 如何在python中循环列表时动态创建df?
- c# - 通过 .net core smtpClient 发送邮件:SmtpException / FormatException
- c++ - 如何删除指向没有虚函数且没有继承的类的指针