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