添加回车功能

This commit is contained in:
huangdeliang
2021-03-03 14:36:21 +08:00
parent 7e97f8510f
commit 333f930b8c
2 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,7 @@
:step="5" :step="5"
:value="value" :value="value"
@blur="handleOnBlur" @blur="handleOnBlur"
@keyup.enter="handleEnterClick"
/> />
</div> </div>
</template> </template>
@ -34,7 +35,7 @@ export default {
const { value } = e.target; const { value } = e.target;
if (value > 0) { if (value > 0) {
this.editing = false; this.editing = false;
const mValue = parseFloat(value) const mValue = parseFloat(value);
if (mValue !== parseFloat(this.value)) { if (mValue !== parseFloat(this.value)) {
this.$emit("onChange", mValue); this.$emit("onChange", mValue);
} }
@ -42,6 +43,9 @@ export default {
this.$message.error("数字必须大于0"); this.$message.error("数字必须大于0");
} }
}, },
handleEnterClick(e) {
e.target.blur();
},
}, },
}; };
</script> </script>

View File

@ -327,9 +327,10 @@ export default {
this.deleteDishes({ num: this.num, id: data.id }); this.deleteDishes({ num: this.num, id: data.id });
}, },
handleOnWeightChange(data, weight) { handleOnWeightChange(data, weight) {
console.log({ data, weight }); // console.log({ data, weight });
this.updateDishes({ this.updateDishes({
num: this.num, num: this.num,
id: data.id,
dishesId: data.dishesId, dishesId: data.dishesId,
igdId: data.igdId, igdId: data.igdId,
weight, weight,