Skip to content

Commit

Permalink
refactor: use createApp & app.use vue 3 API
Browse files Browse the repository at this point in the history
Vue can no longer be imported from `vue`. Instead, we need to create
a vue app instance and "install" our components on the app.
  • Loading branch information
luqven committed Apr 20, 2021
1 parent 461fdf5 commit b583a39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import VueImgix from '@/plugins/vue-imgix';
import Vue from 'vue';
import App from './App.vue';

Vue.config.productionTip = false;
const app = Vue.createApp(App);

Vue.use(VueImgix, {
app.use(
VueImgix, {
domain: 'assets.imgix.net',
defaultIxParams: {
auto: 'format',
},
});

new Vue({
render: (h) => h(App),
}).$mount('#app');
}).mount('#app');
10 changes: 5 additions & 5 deletions src/plugins/vue-imgix/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import _Vue from 'vue';
import _App from './App.vue';
import { IxPicture } from './ix-picture';
import { IxSource } from './ix-source';
import { IVueUseImgixOptions } from './types';
import { initVueImgix, IxImg } from './vue-imgix';

// Declare install function executed by Vue.use()
export function install(Vue: typeof _Vue, options: IVueUseImgixOptions) {
export function install(App: typeof _App, options: IVueUseImgixOptions) {
if (install.installed) return;
install.installed = true;
initVueImgix(options);
Vue.component('ix-img', IxImg);
Vue.component('ix-picture', IxPicture);
Vue.component('ix-source', IxSource);
App.use('ix-img', IxImg);
App.use('ix-picture', IxPicture);
App.use('ix-source', IxSource);
}
install.installed = false;

Expand Down

0 comments on commit b583a39

Please sign in to comment.