Nativescript - 如何禁用 return 键以在可编辑的 TextView 中添加换行符
Nativescript - How to disable the return key to add newline in editable TextView
Official Documentation of Nativescript TextView
根据上面的 link,有一个名为 returnKeyType
的属性。但它不起作用...
还有其他正确的方法来设置returnKeyType吗?或者在按下 return
键时简单地禁用 newline
?
谢谢!
有一个 open feature request, but there is also a workaround 目前应该可以使用,只需使用 1
而不是示例中的 3
。
我不明白,如果你只需要一行,为什么不使用TextField 而不是TextView? TextField 完全符合您的要求。
试试这个,这是适合您的情况的方法
let tv = <TextView>page.getViewById("tv");
tv.on("blur", () => {
tv.text = tv.text.replace(/\n/gm, " ");
})
Official Documentation of Nativescript TextView
根据上面的 link,有一个名为 returnKeyType
的属性。但它不起作用...
还有其他正确的方法来设置returnKeyType吗?或者在按下 return
键时简单地禁用 newline
?
谢谢!
有一个 open feature request, but there is also a workaround 目前应该可以使用,只需使用 1
而不是示例中的 3
。
我不明白,如果你只需要一行,为什么不使用TextField 而不是TextView? TextField 完全符合您的要求。
试试这个,这是适合您的情况的方法
let tv = <TextView>page.getViewById("tv");
tv.on("blur", () => {
tv.text = tv.text.replace(/\n/gm, " ");
})