<body>
    <div id="app">
        <input type="button" value="Click" @click="DoIt (666, 'brother')">
        <input type="text" @keyup.enter="sayHi">
    </div>

    <script src=".. /js/vue.js"></script>
    <script>
        const app = new Vue({
        el: '#app'.methods:  {
            doIt: function (p1,p2) {
                console.log("Do IT");
                console.log(p1);
                console.log(p2);
            },
            sayHi: function () {
                alert("Have you eaten?")}}})</script>
</body>
Copy the code
  • When the button is clicked, the bound click event is triggered. The two defined parameters are passed in. The two parameters can be of different types

  • When you type something, press Enter will pop up the message in alert