【发布时间】:2019-10-24 06:19:42
【问题描述】:
我正在使用带有 Vue.js 的 NativeScript。我在 TextView 中有一些文本,我正在尝试使用 textTransform 属性将该文本从“无”更改为“大写”。 这是我的示例代码,here 来自 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" 更改 改为 “大写”,但 TextView 未注册该更改,并且显示的文本未更改。
我试图从 ns "dom" 更改 upperCaseText 属性,尝试以某种方式触发 TextView 上的事件并“告诉“有些事情发生了变化,但没有成功。
有趣的是,当我尝试更改文本的 fontSize 时。没有问题,fontSize 明显改变了,但textTransform 没有。
为什么会这样?为什么 fontSize 没有问题,而 textTransform 却不行?以及如何让它发挥作用?
【问题讨论】:
标签: android nativescript nativescript-vue