[Vue.js] 捕捉用户键盘输入事件

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue - 我的学习</title>
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>

<body>
<div id="app">
    <input @keyup.space="logSpace">
</div>
<script>
var vm = new Vue({
    el: "#app",
    methods: {
        logSpace: function () {
            console.log("捕捉到用户输入 SPACE !");
        }
    }
})
</script>
</body>
</html>

推荐阅读更多精彩内容