V
V
Vic Shostak2017-09-28 09:22:17
typescript
Vic Shostak, 2017-09-28 09:22:17

vue.js. Integrating third-party vue plugins into a project using a TypeScript template?

Good day!
I'm starting to quietly pick TypeScript. Since, best of all, “picking” goes on examples, I started to make a simple SPA-blog. Since I only know Vue.js of all modern JS frameworks, I chose this starter template for it (set, of course, through vue-cli): https://github.com/ducksoupdev/vue-webpack-typescript
So Here is the question: how is the integration of third-party vue plugins and their call in components now going on? For example, the same vue-meta ? I do everything as usual:
Import the plugin in Initialization and configuration (ibid.)./src/main.ts
import Meta from 'vue-meta';

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

Next, I try to call it in the component ( ./src/components/home/home.ts)
export class HomeComponent extends Vue {
  
  static head() {
    return {
      title: 'Test'
    }
  }

}

But nothing happens. There are no errors either.
Please tell me what I'm doing wrong and how to do it.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danakt Frost, 2017-09-28
@Danakt

import * as Meta from 'vue-meta'

K
Klein Maximus, 2017-09-28
@kleinmaximus

What do you want to achieve with these settings?
Vue.use is just about installing and configuring the plugin itself into the application.
Head elements are changed in components via metaInfo.
Try replacing static head() with static metaInfo().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question