溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

vue常用命令v-on

發(fā)布時(shí)間:2020-06-11 15:03:37 來源:網(wǎng)絡(luò) 閱讀:566 作者:811427792 欄目:開發(fā)技術(shù)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>v-on</title>
    </head>
    <script type="text/javascript" src="js/vue.js" ></script>
    <script>
        window.onload = function(){
            //配置是否允許檢查代碼,方便調(diào)試,生產(chǎn)環(huán)境中設(shè)置為false
            Vue.config.devtools = true;  //檢查代碼
            Vue.config.productioinTip = false;  //有強(qiáng)迫癥的,可以關(guān)掉生產(chǎn)中的提示信息
            let vm = new Vue({
                el: "#div1",
                data:{
                    arr: [1,2,3,4,5],
                },
                methods:{
                    show:function(){
                        console.log('這是show方法');
                    },
                    add:function(){
                        this.arr.push(999);  //this表示訪問當(dāng)前實(shí)例中的成員
                    }
                }
            });
        }
    </script>
    
    <body>
        <div id="div1">
            <button v-on:click="show()">show方法</button>
            <br>
            <button v-on:click="add()">向數(shù)組添加一個(gè)元素</button>
            <br>
            <br>數(shù)組:`arr`
            <br>
            <button v-on:mouseover="show()">鼠標(biāo)經(jīng)過</button>
            <br>
            <button v-on:dblclick="show()">鼠標(biāo)雙擊</button>
        </div>
    </body>
</html>

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

on vue v
AI