美文网首页我爱编程
Vue局部自定义指令

Vue局部自定义指令

作者: 郭的妻 | 来源:发表于2018-06-04 09:31 被阅读3次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="vue.js"></script>
    </head>
    <body>
    <div id="app">
        <input type="text" v-focus>
    </div>
    <script>
        new Vue({
            el:'#app',
            directives:{
                focus:{
                    // 指令的定义
                    inserted: function (el) {
                        el.focus()
                    }
                }
            }
        })
    </script>
    </body>
    </html>  

    相关文章

      网友评论

        本文标题:Vue局部自定义指令

        本文链接:https://www.haomeiwen.com/subject/bxresftx.html