问题描述
我正在为vue指令键入脚本,但是似乎无法找到应该为Vue安装功能使用哪种类型。
和rt = re.search('\d{2}:\d{2}',line)
if rt: # if rt is None then rt.group() will raise an exception
rtime = time.strftime(rt.group(),'%M:%s')
rtime.total_seconds()
在一起似乎有些奇怪。
我曾尝试导入Vue,然后使用install(Vue: any): void
,但抛出一个错误,表明Vue上没有install(Vue: Vue)
,这也是很奇怪的。
如何键入安装功能? .directive
类型是否可以在这里工作?我在这里想念什么,还是Vue
错过了什么?
Vue
解决方法
您想要的类型是VueConstructor
。这是Typescript Vue插件的创作方式
import { VueConstructor,PluginObject,DirectiveOptions } from "vue"
const directive: DirectiveOptions = {
bind(elem,bind,vn) {
console.log('bound')
}
}
const plugin: PluginObject<any> = {
install (Vue: VueConstructor): void {
Vue.directive("do-stuff",directive)
}
}
export default plugin