2

How to include Vue plugins to Vue TypeScript's template, like vue-webpack-typescript?

For example, vue-meta.

I already add to ./src/main.ts this:

import * as Meta from 'vue-meta';

Vue.use(Meta, {
  keyName: 'head', 
  attribute: 'data-vue-meta', 
  ssrAttribute: 'data-vue-meta-ssr', 
  tagIDKeyName: 'vmid'
});

And add this to ./src/components/home/home.ts component:

export class HomeComponent extends Vue {

  static head() {
    return {
      title: 'Test'
    }
  }

}

But this not working, don't show over written title..

2 Answers 2

1

It's nothing to do with including Vue plugins I suppose. If you correctly set typescript compiler to work with vue, the component would use whatever the plugins are. So I guess it would be the issue of your using the class-style component.

According to the Vue's official example, you'll need vue-class-component to make Vue recognize class components. https://v2.vuejs.org/v2/guide/typescript.html#Class-Style-Vue-Components

@Component
export class MyMixin extends Vue {
  mixinValue = 'Hello'
}

Good luck!

Sign up to request clarification or add additional context in comments.

Comments

0

Maybe you should write this in Component decorator:

@Component({
  head () {
    return {
      title: 'test'
    }
  }
})
export class Test extends Vue {}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.