vue-touch-events: Failed to resolve directive: touch

Using this library into another library and then importing the 2nd library doesn’t work.

We have a Modal component on the https://github.com/nextcloud/nextcloud-vue library and we wanted to use your library, though when importing the modal component on another app, we get the Failed to resolve directive: touch error.

Though importign and using your library on the nextcloud-vue library is done properly:

import Vue from 'vue'
import Vue2TouchEvents from 'vue2-touch-events'

Vue.use(Vue2TouchEvents)

I’m guessing this is because you don’t export your plugin as a ssr module or something webpack can understand and pack and bundle on other libraries. But I might be wrong! 😃

EDIT: I was close, this is because you do not export the directive itself but only the {install:xxx, …} object Vue.use requires. Please check https://github.com/Akryum/v-tooltip/blob/master/src/index.js for a working example. It exports the vue directive as well so that webpack can understand how things works and include everything.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 4
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Is there any option to define a custom directive when installing? I’am using Vuetify and the component “v-touch” seems to override this package.

import Vue2TouchEvents from 'vue2-touch-events';
Vue.use(Vue2TouchEvents);

I had the same issue and it was caused by having 2 plugins in the same Vue.use. I changed Vue.use(Argon, Vue2TouchEvents); to

Vue.use(Argon);
Vue.use(Vue2TouchEvents);