2022-10-22 13:52阅读: 14评论: 0推荐: 0

按键修饰符

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="vue.js"></script>
</head>
<body>
<div id="app">
    <!--    方式1-->
    <input type="text" @keyup="handleKey1($event)">
    <!--    方式二,无需判断段code-->
    <input type="text" @keyup.enter="handleKey2($event)">
</div>
</body>
<script>
    const app = Vue.createApp({
        data() {
            return {}
        }, methods: {
            handleKey1(event) {
                if (event.code == 'Enter') {
                    console.log("Enter")
                }
            },
            handleKey2(event) {
                console.log("Enter")

            }
        }
    }).mount('#app')
</script>
</html>

本文作者:Sherwin

本文链接:https://www.cnblogs.com/sherwin1995/p/16815989.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Sherwin_szw  阅读(14)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.