-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use vue 3 global and composition api in ix-picture
- Loading branch information
Showing
1 changed file
with
9 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { ensureVueImgixClientSingleton, IVueImgixClient } from './vue-imgix'; | ||
import Vue, { CreateElement } from 'vue'; | ||
import Component from 'vue-class-component'; | ||
import { defineComponent, h } from 'vue'; | ||
|
||
const IxPictureProps = Vue.extend({ | ||
const IxPictureProps = defineComponent({ | ||
props: {}, | ||
}); | ||
|
||
@Component | ||
export class IxPicture extends IxPictureProps { | ||
// Using !: here because we ensure it is set in created() | ||
private vueImgixSingleton!: IVueImgixClient; | ||
export const IxPicture = defineComponent({ | ||
mixins: [IxPictureProps], | ||
render() { | ||
const vueImgixSingleton: IVueImgixClient = ensureVueImgixClientSingleton(); | ||
|
||
created() { | ||
this.vueImgixSingleton = ensureVueImgixClientSingleton(); | ||
} | ||
|
||
render(createElement: CreateElement) { | ||
return createElement('picture', this.$slots.default); | ||
} | ||
} | ||
return h('picture', this.$slots.default); | ||
}, | ||
}); |