微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 ValueChanged 来更改我的输入类?

如何解决如何使用 ValueChanged 来更改我的输入类?

我有两个组件。IPB 是父组件,IPB_BrakeDurability 是子组件。

我想在值改变时改变子组件的 inputClass,我该如何使用 valuechanged 事件??非常感谢。以下是两个组件。

IPB.razor(使用 IPB_BrakeDurability 组件。)

<IPB_BrakeDurability IPBTI_BrakeDurability="@IPBTI.IPBTI_BrakeDurability" />
@code {
    IPBTI IPBTI;
    double[] deceleration = { 0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,1.20,1.25,1.30 };
    double[] frequencyMotion = { 205033,639927,404300,200177,84266,35147,14463,7168,3893,2144,1252,745,466,332,198,91,77,63,52,41,32,25,19,14,10,65 };
    double[] frequencyStandstill = { 84569,243706,115070,56182,25350,16912,12771,9810,7793,5892,4585,3474,2718,2218,1613,1067,995,917,831,739,640,534,421,301,175,717 };

protected override void OnInitialized()
    {
        base.OnInitialized();
        IPBTI = new IPBTI();
        IPBTI.IPBTI_BrakeDurability = new IPBTI_BrakeDurability { Deceleration = deceleration,FrequencyMotion = frequencyMotion,FrequencyStandstill = frequencyStandstill };
    }
}

IPB_BrakeDurability.razor

<MatTextField Value="@IPBTI_BrakeDurability.FrequencyMotion[0]" TValue="double" ValueChanged="@(()=>SetInputClass())" InputClass="@inputClass" />

<style>
    .text-field-class {
        font-family: monospace;
        color: red !important;
    }
</style>

@code {
    [Parameter]
    public IPBTI_BrakeDurability IPBTI_BrakeDurability { get; set; }


    string inputClass=string.Empty;
    private string SetInputClass()
    {
        inputClass = "text-field-class";
        return inputClass;
    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。