TypechoJoeTheme

香草物语

统计
登录
用户名
密码
/
注册
用户名
邮箱
输入密码
确认密码

ElementUI中el-input-number实时监听值变化

Laughing博主
2024-05-29
/
0 评论
/
498 阅读
/
124 个字
/
百度已收录
05/29
本文最后更新于2024年05月29日,已超过111天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

在前端开发过程中,我们经常会遇到将金额转大写的情况,我们要实现的效果,是只要输入就实时计算大写,而不是等全部输入完成失去焦点后。

如果使用ElementUI框架的el-input-number控件的@input事件,是无法达到实时显示效果的。

html代码


<el-col :span="24">
    <el-form-item label="本次报价" prop="quotationPrice">
        <el-input-number
            :precision="2"
            :step="100"
            :max="10000000"
            :min="0"
            v-model="form.quotationPrice"
            style="width: 100%"
            controls-position="right"
            data-unit="元"
            placeholder="请输入本次报价"
            ref="refQuotationPrice"
            @input.native="convertPrice2CnyMoney"
            @change="convertPrice2CnyMoney4Change"
        />
    </el-form-item>
</el-col>
<el-col :span="24">
    <el-form-item label="总金额" prop="cnyMoney">
        <div class="cnyMoney">{{ cnyMoney }}</div>
    </el-form-item>
</el-col>

JavaScript代码

//本次报价金额实时转大写
convertPrice2CnyMoney(event) {
    let value = this.$refs.refQuotationPrice.displayValue;
    this.cnyMoney = numToCny(value);
},
//本次报价金额实时转大写
convertPrice2CnyMoney4Change(val) {
    this.cnyMoney = numToCny(val);
}
Element UI
朗读
赞(0)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

香草物语

本文链接:

https://www.xiangcaowuyu.net/web/real-time-monitoring-of-el-input-number-values-in-elementui.html(转载时请注明本文出处及文章链接)

评论 (0)