b-form-input不接受普通HTML输入中的最小值

问题描述 投票:0回答:1

我目前正在使用,但是当我使用最小值时,它可以工作,但是在控制台上收到错误。 “对于属性“ min”的类型检查失败。期望的数字,为String。”。我不知道该怎么办,我已经尝试过一些同事建议的不同名称,例如minvalue,但也没有用。

这里是我的代码:

<template>
  <div>
    <b-btn @click="showModal">Editar</b-btn>
    <!-- Modal Component -->
    <b-modal ref="myModalRef"
             centered title="Editar"
             ok-title="Salvar"
             cancel-title="Cancelar"
             v-on:cancel="handleCancel"
             v-on:ok="handleOk(hours)">
      <form>
        <b-form-input type="number"
                      min="0"
                      placeholder="Horas"
                      v-model="hours"></b-form-input>
      </form>
    </b-modal>
  </div>
</template>

<script>
import tableData from './index';

export default {
  components: {
    tableData,
  },
  props: {
    table: {
      type: Array,
      required: true,
    },
    row: {
      required: true,
    },
  },
  data() {
    return {
      hours: '',
    };
  },
  methods: {
    handleOk(hours) {
      if (hours !== '' || hours < 0) {
        const id = this.row - 1;
        const oldReport = this.table[id];
        const newReport = {
          hours: this.hours,
          costCenter: oldReport.costCenter,
          period: oldReport.period,
        };
        console.log(oldReport) // eslint-disable-line
        this.table.splice(id, 1, newReport);
        this.$snotify.success('Suas horas foram atualizadas', 'Sucesso', {
          timeout: 2000,
          showProgressBar: false,
          closeOnClick: false,
          pauseOnHover: true,
        });
      } else {
        this.$snotify.error('Digite um número válido');
      }
    },
    handleCancel() {
    },
    showModal() {
      this.$refs.myModalRef.show();
    },
    hideModal() {
      this.$refs.myModalRef.hide();
    },
    clearModal() {
      this.hours = '';
    },
    onChange(e) {
      this.tableCenter.map(item => item.id).indexOf(e);
      this.hours = '';
    },
  },
};
</script>
html vue.js bootstrap-4 bootstrap-modal
1个回答
0
投票

我查看了您的问题,并在我的机器上尝试过,这是您应该做的

替换min =“ 0”,其中0被读取为字符串,并替换为min = 0。希望有帮助

© www.soinside.com 2019 - 2024. All rights reserved.