【问题标题】:b-form-input don't accept a minimum number as in normal HTML inputsb-form-input 不接受正常 HTML 输入中的最小数字
【发布时间】:2018-10-15 05:03:57
【问题描述】:

我目前正在使用,但当我使用最小值时,它可以工作,但我在控制台收到错误消息。 “道具“min”的类型检查失败。预期的数字,得到了字符串。”。我不知道还能做什么,我已经按照一些同事的建议尝试了不同的名称,例如 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】:

我看了你的问题并在我的机器上试了一下,你应该这样做

替换 min="0" 将 0 读取为字符串并替换为 min=0。希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-25
    • 2020-11-01
    • 2021-12-20
    • 2021-11-13
    • 2016-09-20
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    相关资源
    最近更新 更多