组件A的样式不能在文本组件中动态修改。我怎么解决这个问题?

The style of component A cannot be dynamically modified in the text component. How can I solve this problem?

当我在文本组件中放置组件A时,样式中的文本颜色被绑定。如果改变bound textcolor的值,组件A的文本颜色将无法改变。例如,如果您希望将文本颜色从蓝色更改为红色。示例代码:

模板中的代码:

<text>
        <a href="https://huawei.com" style="color: {{textcolor}};" value="click here"></a>
    </text>
     <input type="button" value="Change the text color of component a." onclick="changeColor" />

脚本中的代码:

changeColor: function() {
      this.textcolor="red";
    }

A​​组件放置在文本组件中时,快应用框架不支持动态更改样式

可以将动态样式绑定到外层的文本组件上,实现变色效果。示例代码如下(见红色部分):

<text style="color: {{textcolor}};">
      <a href="https://huawei.com" value="click here"></a>
</text> 

效果(点击按钮后):

更多详情,请查看:

快应用文档:https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-whitepaper?ha_source=hms1