Tue Jun 20 09:07:00 UTC 2023 inscode

上级 4d66faa6
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
<form @submit.prevent="submitForm"> <form @submit.prevent="submitForm">
<textarea style="width: 100%;" v-model="inputText" cols="30" rows="10"></textarea> <textarea style="width: 100%;" v-model="inputText" cols="30" rows="10"></textarea>
<br> <br>
<button type="submit">提交</button> <button type="submit" id="submit">提交</button>
</form> </form>
<textarea style="width: 100%;" name="output" id="" cols="30" rows="10">{{ this.msg.outputText }}</textarea> <textarea style="width: 100%;" name="output" id="output" cols="30" rows="10">{{ this.msg.outputText }}</textarea>
<button id="btn_copy" onclick="copy()">复制</button>
<textarea v-if="this.msg.error" style="width: 100%;" id="errorMessage" rows="10">{{ this.msg.error }}</textarea> <textarea v-if="this.msg.error" style="width: 100%;" id="errorMessage" rows="10">{{ this.msg.error }}</textarea>
</div> </div>
</template> </template>
...@@ -31,7 +32,7 @@ export default { ...@@ -31,7 +32,7 @@ export default {
}); });
}, },
methods: { methods: {
submitForm() { // 处理提交逻辑 submitForm() {
axios axios
.post("http://localhost:8080/about", { .post("http://localhost:8080/about", {
inputText: this.inputText inputText: this.inputText
...@@ -42,17 +43,27 @@ export default { ...@@ -42,17 +43,27 @@ export default {
.catch((err) => { .catch((err) => {
}); });
}, },
}, handleKeyDown(event) {
console.log('test-key', event.keyCode)
}; if (event.key === "F5") {
document.onkeydown = function (event) {
if (event.key === 'F5') {
event.preventDefault(); event.preventDefault();
this.submitForm();
} }
},
},
mounted() {
document.addEventListener("keydown", this.handleKeyDown);
},
beforeDestroy() {
document.removeEventListener("keydown", this.handleKeyDown);
},
};
function copy() {
document.getElementById("output").select()
document.execCommand('copy');
} }
</script>
<!-- Add "scoped" attribute to limit CSS to this component only --> </script>
<style scoped> <style scoped>
h1, h1,
h2 { h2 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册