image.png

代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js事件中如何读取data里面的数值</title>
    <script src="//static.gzj2001.com/vue/vue.js"></script>
</head>
<body>
    <div id="app">
        <button v-on:click="test">点击</button>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                shuxing1:"城南花开"
            },
            methods:{
                test:function(event){
                    alert(this.shuxing1);
                    if(event){
                    alert(event.target.tagName);
                }
                }
                
            }
        })
    </script>
</body>
</html>