自定义命令统一管理,装饰器统一管理
This commit is contained in:
		| @@ -1,29 +1,15 @@ | ||||
| //本地仓库外部组件 | ||||
|  | ||||
| // 存储组件列表 | ||||
| import directives from "../lib/js/directives"; | ||||
|  | ||||
| let components = []; | ||||
| // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 | ||||
| const install = function (Vue) { | ||||
|   if (install.installed) return; | ||||
|   // 遍历注册全局组件 | ||||
|   let contexts = require.context('.', true, /[\\\/]Ai([^\\\/]+)\.vue$/); | ||||
|   Vue.directive('throttle', { | ||||
|     bind: function (el, obj) { | ||||
|       let timerId = null | ||||
|       let flag = true | ||||
|  | ||||
|       el.addEventListener('input', function () { | ||||
|         if (!flag) return | ||||
|  | ||||
|         flag = false | ||||
|         timerId && clearTimeout(timerId) | ||||
|         timerId = setTimeout(function () { | ||||
|           flag = true | ||||
|           obj.value() | ||||
|         }, 800) | ||||
|       }) | ||||
|     } | ||||
|   }) | ||||
|   Vue.use(directives) | ||||
|   if (contexts) { | ||||
|     contexts.keys().map((e) => { | ||||
|       components.push(contexts(e).default); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user