我目前正在使用,但是当我使用最小值时,它可以工作,但我在控制台上收到错误。 "对于道具" 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>
答案 0 :(得分:0)
我查看了您的问题,并在我的机器上尝试过,这是您应该做的事
替换 min =“ 0” ,将0读取为字符串,并替换为 min = 0 。希望有帮助