diff --git a/examples/vue-router/Options.ts b/examples/vue-router/Options.ts
index cff295f..f4d7e48 100644
--- a/examples/vue-router/Options.ts
+++ b/examples/vue-router/Options.ts
@@ -1,6 +1,16 @@
-export default {
- metaInfo: {
- title: 'Title from Options API'
+import { defineComponent } from 'vue'
+
+export default defineComponent({
+ data () {
+ return {
+ title: 'Data Title'
+ }
+ },
+ metaInfo () {
+ const title = this.title
+ return {
+ title: title + ' from Options API'
+ }
},
template: '
This component uses the Options API
'
-}
+})
diff --git a/src/plugin.ts b/src/plugin.ts
index c402c3a..70cd624 100644
--- a/src/plugin.ts
+++ b/src/plugin.ts
@@ -21,7 +21,7 @@ export const createMixin: CreateMixin = options => ({
const metaInfo = (instance.type as any)[options.keyName] as ComponentOptionsMetaInfo
if (isFunction(metaInfo)) {
- const computedMetaInfo = computed(metaInfo)
+ const computedMetaInfo = computed(metaInfo.bind(this))
useMeta(computedMetaInfo)
} else {
useMeta(metaInfo)
diff --git a/src/types/options.ts b/src/types/options.ts
index 436260e..fe28227 100644
--- a/src/types/options.ts
+++ b/src/types/options.ts
@@ -1,3 +1,5 @@
+import { ComponentOptionsMixin } from 'vue'
+
export interface AttributeProperty {
[key: string]: string | string[]
}
@@ -129,4 +131,5 @@ export interface ComponentMetaInfo {
noscript?: NoScriptProperty[]
}
-export type ComponentOptionsMetaInfo = ComponentMetaInfo | (() => ComponentMetaInfo)
+// TODO: how to infer the real component options in this?
+export type ComponentOptionsMetaInfo = ComponentMetaInfo | ((this: ComponentOptionsMixin) => ComponentMetaInfo)