自定义指令

定义全局:

 

1 1 Vue.directive('mydirective', {
2 2     bind: function (el) {},
3 3     inserted: function () {},
4 4     updated: function () {}
5 5 });

 

 

注意:定义的时候不写v-,使用的时候加上v-。

 

定义私有:

 

 1 var vm = new Vue({
 2     el: '#app',
 3     data: {
 4     }
 5     methods: {
 6     },
 7     filters: {
 8     }, 
 9     directives: {
10         'mydirective': {
11 
12         }
13     }
14 });

 

posted @ 2021-09-01 21:12  agetoage  阅读(39)  评论(0)    收藏  举报