vue click event, how to add vue click

The first step
is to fill in the div element in the html file, and add button information in the middle

<html>
      
        <div>
            <input type="button" value="hamimelon!" />
        </div>

</html>

The second step
consider associating click events

First thought:
add

<html>
        <div>
            <input type="button" value="hamimelon!" />
        </div>
</html>
<script>
   
</script>

Second thought: It seems that this is not right

<html>
    <div>
        <input type="button" @click="display_alert" value="hamimelon!" />
    </div>
</html>
<script>
export default {
    
    
    data:{
    
    
        name:display_alert
        alert("完成vue的点击事件")
    }
}
</script>

Guess you like

Origin blog.csdn.net/weixin_40945354/article/details/115239756