<template>
  <input
    class="filter_input"
    type="number"
    :value="value"
    :placeholder="placeholder"
    @input="onInput"
	@confirm="onInput"
  />
</template>

<script>
export default {
  props: {
    value: {
      type: [Number, String],
      default: '',
    },
	placeholder: String
  },
  methods: {
    onInput(event) {
      // 获取输入值
      const value = event.detail ? event.detail.value : event.target.value;
      // 格式化输入值
      let formattedValue = value.replace(/[^0-9.]/g, '')
	  formattedValue = parseFloat(formattedValue)
	  formattedValue = formattedValue > 0 ? formattedValue : ''
      this.$emit('input', formattedValue);
	  event.target.value = formattedValue
    }
  },
};
</script>
