有时候,我们需要给元素绑定事件,vue 中提供了指令 v­-on 来进行事件的绑定。用法:


v­-on:事件名="方法",例如:v­-on:click=“alert”。

v-­on:事件名, 可以缩写为: @事件名

<!DOCTYPE html>
<html lang="en">

<head>
    
    
    
    <title>Document</title>
</head>


    <div>
        <button v‐on:click="hello">hello</button>
    </div>




</html>