首页 > 解决方案 > Vue使用按钮更改输入字段中的文本

问题描述

我在更改输入文本字段中的文本时遇到问题。我想让用户使用“开始”按钮来启动我的应用程序:当用户单击提交时,这应该在文本字段中写入小时和分钟,并且对于“结束”按钮也是如此。这些时间和其他时间将在火力基地上开火。感谢您的帮助,这是我的代码:

<template>
            ...
            <label>Start Time:</label>
            <input type="text" v-model="newAct.startTime" disabled/><br>
            <label>End Time:</label>
            <input type="text" v-model="newAct.endTime" disabled/><br>
            <button @click="submitStart">Start</button>
            <button @click="submitEnd">Stop</button>
            ...
</template>

有我的代码:

<script>
...
export default {
...
    submitStart() {
      let t = new Date();
      let time = t.getHours() + ":" + t.getMinutes();
      newAct.StartTime = time;
    },
    submitEnd() {
      let t = new Date();
      let time = t.getHours() + ":" + t.getMinutes();
      newAct.EndTime = time;
    }
  }
...
</script>

标签: buttoninputtextvue.js

解决方案


推荐阅读