Closed kfina91 closed 3 years ago
The issue seems to be with your Vue import. It seems Vue isn't being imported as the 'undefined' is referring to the Vue instance.
Thanks for the quick answer! I have searched where the problem with my Vue import, but don't see a problem there.
I tried setting up an empty vue3 project with just panZoom and it failed with the same error message. But it should be much easier to reproduce.
import { createApp } from 'vue'
import App from './App.vue'
import panZoom from 'vue-panzoom'
createApp(App).use(panZoom).mount('#app')
5. Add `<panZoom>Test</panZoom>` to src/App.vue
6. npm run serve
Getting the same error as in my last post. I am not familiar with the internal workings of the Vue app instance and how hooking custom components work, but maybe they changed something in vue3 regarding that?
P.S. By setting a breakpoint in the browser it seems that in the installation function:
var PanZoomPlugin = { install: function install(Vue, options) { var _name = options && options.componentName ? options.componentName : PanZoomComponent.name; Vue.component(_name, PanZoomComponent); Vue.prototype.$panZoom = panZoom; } };
Vue is set to some object it contains various properties, only prototype is undefined.
![image](https://user-images.githubusercontent.com/72922128/114241923-48bfd480-998a-11eb-8338-6ed680202e5f.png)
Hi, I've fixed this in v1.1.5. Kindly update and try again. I didn't realize this change in Vue 3. Thanks for reporting this.
Hey, everything is working fine now. Thank you for the update!
I'm trying to get this to run with laravel/inertia + vue3.
app.js (I added 2 lines to the boilerplate from laravel/jetstream with inertia, see comments)
MyComponent.vue
I get the following error _Uncaught TypeError: Cannot set property '$panZoom' of undefined at Object.install (app.js:50218) at Object.use (app.js:8680) at Module../resources/js/app.js (app.js:23584) at webpack_require (app.js:50873) at app.js:51035 at Function.webpack_require.O (app.js:50910) at app.js:51037 at app.js:51039_ this corresponds to the following code in dist/vue-panzoom.esm.js:123
package.json
Note: I also tried in app.js
but this leads to (when running npm run dev): WARNING export 'default' (imported as 'Vue') was not found in 'vue' and (in the browser): Cannot read property 'use' of undefined (in the line Vue.use(panZoom))
Any help would be much appreciated! Thanks in advance!