You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

b-form-input设置min属性触发类型校验错误问题咨询

Fixing the "Expected Number, got String" Error for b-form-input's min Prop

Hey there! Let's get that console warning sorted out for you. The issue here is super straightforward once you know how Vue handles prop types and attribute bindings.

Why the Error Happens

BootstrapVue's b-form-input component expects the min prop to be a Number type when used with numeric input types (like type="number"). When you write min="10" without any binding, Vue treats that value as a string—even though the browser might still interpret it correctly for validation, Vue's prop type check will flag it with that warning.

The minvalue prop you tried doesn't exist in b-form-input's API, so that's why it didn't fix anything.

The Fix

You just need to use Vue's v-bind syntax (the colon : shortcut) to pass the value as a number instead of a string. Here's how to adjust your code:

Before (causes warning):

<b-form-input type="number" min="5" placeholder="Enter a number..." />

After (fixes the warning):

<b-form-input type="number" :min="5" placeholder="Enter a number..." />

If your min value comes from a data property or computed value, just make sure that property is a Number, then bind it normally:

<template>
  <div>
    <b-btn @click="showModal">Editar</b-btn>
    <b-modal ref="myModalRef" centered title="Editar" ok-title="Guardar">
      <b-form-input 
        type="number" 
        :min="minimumValue" 
        placeholder="Ingresa un valor..."
      />
    </b-modal>
  </div>
</template>

<script>
export default {
  data() {
    return {
      minimumValue: 0 // This is a Number, not a string!
    }
  },
  methods: {
    showModal() {
      this.$refs.myModalRef.show()
    }
  }
}
</script>

Why This Works

Using :min="5" tells Vue to evaluate the value inside the quotes as JavaScript (so 5 is treated as a number) instead of treating it as a plain string. This matches the prop type that b-form-input expects, so the type check passes and the warning disappears.

Your input's validation functionality will keep working exactly as before—you just get rid of that annoying console warning.

内容的提问来源于stack exchange,提问作者Igor Formiga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:08:08