Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement currency filter in vue

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article Xiaobian for you to introduce in detail "vue how to achieve the currency filter", the content is detailed, the steps are clear, the details are handled properly, I hope this "vue how to achieve the currency filter" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

So for the component's v-model to take effect, it must:

Accept a value attribute

The input event is triggered when there is a new value

The code is as follows:

HTML:

{{message}}

Total: ${{total}}

JavaScript:

Vue.component ('currency-input', {template: `\ {label}}\ $\`, props: {value: {type: Number, default: 0}, label: {type: String, default:''}}, mounted: function () {this.formatValue ()}, methods: {updateValue: function (value) {var result = currencyValidator.parse (value) This.value) if (result.warning) {this.$refs.input.value = result.value} this.$emit ('input', result.value)}, formatValue: function () {this.$refs.input.value = currencyValidator.format (this.value)}, selectAll: function (event) {setTimeout (function () {event.target.select ()}, 0)}}) new Vue ({el:' # app' Data: {message: 'Hello Vue.jskeeper, price: 0, shipping: 0, handling: 0, discount: 0}, computed: {total: function () {return ((this.price * 100 + this.shipping * 10 + this.handling * 100-this.discount * 10) / 100) .tofixed (2)}})

The effect picture is as follows:

After reading this, the article "how to realize the currency filter in vue" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about the article, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report