【发布时间】:2021-09-16 21:15:52
【问题描述】:
大家好,我正在尝试从 textArea DOM 中获取价值,但它似乎不像常规反应那样工作
val chat = fc<ChatProps> { props ->
val (mess, setMess) = useState("")
div("flex flex-row bg-gray-400 m-4 py-2 px-1 mt-auto") {
textarea(classes = "bg-transparent border-transparent w-full h-full border-opacity-0 " +
"scrollbar-hide w-full h-full") {
attrs.value = mess
attrs.onChange = {
console.log(it.target.nodeValue ?: "")
}
}
it.target.value 在 React 中,it.currentTarget 也不起作用,将事件 T 转换为 HTMLInputElement 也不起作用。它始终为空。这些课程是顺风课程
【问题讨论】:
-
应该
attrs.onChange是一个函数而不是一个语句? -
不确定你的意思@tromgy,它是一个 lambda 函数,它接收 changeEvent 作为参数?
标签: reactjs kotlin kotlin-multiplatform kotlin-js