android - NativeScript TextView:textTransform 无法更新
问题描述
我将 NativeScript 与 Vue.js 一起使用。我在 TextView 中有一些文本,我正在尝试使用 textTransform 属性将该文本从“无”更改为“大写”。这是我的示例代码,这里来自 ns 操场
<template>
<Page class="page">
<ActionBar title="Home" class="action-bar" />
<ScrollView>
<StackLayout>
<TextView editable="false" :fontSize="textFontSize"
:textTransform="upperCaseText">
<FormattedString>
<Span text="This is a text view that uses attributed text. You can use text attributes such as " />
</FormattedString>
</TextView>
<Button text="Make uppercase" @tap="toUpperCase" />
</StackLayout>
</ScrollView>
</Page>
</template>
<script>
export default {
data() {
return {
upperCaseText: "none",
textFontSize: 20
};
},
methods: {
toUpperCase() {
this.upperCaseText = "uppercase";
this.textFontSize = 67;
}
}
};
</script>
当我单击Make uppercase按钮时,属性upperCaseText从"none"更改为"uppercase" ,但TextView未注册该更改,并且显示的文本未更改。
我试图从ns“dom”更改upperCaseText属性,试图以某种方式触发TextView上的事件并“告诉”某些事情已经改变,但没有成功。
有趣的是,当我尝试更改文本的fontSize时。没有问题,fontSize明显改变了,但textTransform没有。
为什么会这样?为什么fontSize没有问题,但textTransform不起作用?以及如何让它发挥作用?
解决方案
由于 Android 的限制,更新文本转换属性不会对已在 TextField / TextView 上设置的文本产生任何影响。更多信息可以在相关的Github 问题中找到。
文本字段和文本视图 (Android)
在这些控件上设置 text-transform 属性不会更改其中的文本。如果您想转换文本,您应该在将其设置为 text 属性之前进行。
我不确定您为什么将 TextView 设为只读(可编辑 =“false”),如果您不想要可编辑的 TextView,那么您可以简单地使用应该支持动态更新文本转换的标签。
推荐阅读
- ftp - 使用 WinSCP 在日期范围内下载文件时“缺少命令 'get' 的参数”
- python - 高维中的numpy非规范点积
- sql-server - 使用 Powershell 脚本输出文件具有相同的重复行
- r - Simba Athena ODBC:无法使用 SQLGetPrivateProfileString 函数
- flutter - 颤动的riverpod ConsumerWidget没有被重建
- typescript - 打字稿:根据参数在函数响应中包含键
- typescript - 不在“rootDir”“c:/Users/hasit/Desktop/typescript/src”下。'rootDir' 应包含所有源文件。”
- installation - 当包管理器尝试从命令行安装它们时,是否可以对所需的 nuget 列表进行排序以使其不崩溃?
- reactjs - React.js:如何在 React 中显示生日字段直到日期?
- android - 当我在 MAINACTIVTY 中添加 INTENT 后尝试运行我的应用程序时,它显示此错误