0
点赞
收藏
分享

微信扫一扫

vue3.x全局自定义指令Cannot read properties of undefined (reading ‘deep‘)

Jonescy 2022-03-11 阅读 204

1.vue3.x全局自定义指令Cannot read properties of undefined (reading ‘deep’)

最近在学习vue3.x的全局自定义指令时,根据官方文档去学习还是出现了问题。就是vue3.x的全局自定义指令,所以记录下来避免踩坑。
这是我报错的全局自定义指令

import { createApp } from 'vue'
import App from './App.vue'

const app = createApp(App)
app.mount('#app')
app.directive('time', {
    beforeMount:(el, binding) => {
        console.log(el, binding, '什么')
    }
})

使用自定义指令
在这里插入图片描述
运行时
发现还是报错了
解决方案:
我是调整了mount方法的调用时机。
在这里插入图片描述
运行成功
在这里插入图片描述

举报

相关推荐

0 条评论