Giter VIP home page Giter VIP logo

Comments (3)

dm4t2 avatar dm4t2 commented on September 10, 2024 1

No, currently not. But a Vue directive for usage with components libs such as Element UI is on the roadmap.

from vue-currency-input.

dm4t2 avatar dm4t2 commented on September 10, 2024

I just released 1.2.0 providing the new v-currency directive. I tested the directive with Element and Vuetify.

Check out the example source:
https://github.com/dm4t2/vue-currency-input/blob/master/docs/.vuepress/components/DirectiveDemo.vue

from vue-currency-input.

fergardi avatar fergardi commented on September 10, 2024

If anyone is interested, I've managed to refactor the given example of element-ui integration into Typescript:

<!-- https://github.com/dm4t2/vue-currency-input/issues/19#issuecomment-514995907 -->
<template>
  <el-input ref="elInput" v-currency="options" :value="formattedValue" @input="handleInput" :placeholder="placeholder"/>
</template>

<script lang="ts">
import { setValue, getValue } from 'vue-currency-input';
import { Component, Vue, Emit, Watch, Prop } from 'vue-property-decorator';
import { ElInput } from 'element-ui/types/input';

@Component({})
export default class ElCurrencyInput extends Vue {

  public formattedValue: string | number | null = null;
  @Prop() private value: any;
  @Prop() private placeholder?: string;

  @Watch('value')
  private onValueChange(value: number, oldValue: number) {
    this.setValue(value);
  }

  @Emit('input')
  private handleInput(value: string): number | null {
    this.formattedValue = value;
    return getValue((this.$refs.elInput as ElInput).$refs.input as HTMLInputElement);
  }

  private setValue(value: number) {
    setValue((this.$refs.elInput as ElInput).$refs.input as HTMLInputElement, value);
  }

  private mounted() {
    this.setValue(this.value);
  }

  get options() {
    return {
      locale: 'de-DE', // 'es-ES' does not have thousands separators in numbers of 4 digits or less, but 'de-DE' does
      currency: null, // to hide the coin,
    };
  }

}
</script>

from vue-currency-input.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.