xinggevip

Vue2.x_1.3键盘事件
app.jsnew Vue({ el:"#vue-app", data:{ ...
扫描右侧二维码阅读全文
15
2019/05

Vue2.x_1.3键盘事件

app.js

new Vue({
    el:"#vue-app",

    data:{

    },

    methods:{
        logName: function () {
            console.log("你正在输入你的名字");
        },

        logAge: function () {
            console.log("你正在输入年龄");
        },
    },
})

Html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    <div id="vue-app">
        <h1>键盘 Events</h1>
        <label>姓名</label><input type="text" v-on:keyup.enter = "logName">
        <label>年龄</label><input type="text" v-on:keyup.enter = "logAge">

    </div>

    <script src="app.js"></script>
</body>
</html>

演示链接

http://hao.qiangssvip.com/vuestudy/Lesson03

Last modification:May 21st, 2019 at 09:21 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment