npm i vue-headful
Register the component:
;;Vue;// your configuration;
And then use the
vue-headful component in every of your views:
vue-headful is only a wrapper around Headful and by itself does not do that much. vue-headful supports all the head properties that are supported by Headful. You can find a non-complete list of head properties in the following example:
If there are any other head properties or attributes you want to set, you can use
html (for arbitrary elements in the whole document) or
head (for elements within
<head>) as follows.
The selectors can be any valid CSS selector.
<!-- Results in:<head><meta charset="utf-8"></head><body id="aPageId"><h1 data-foo="bar"></h1>-->
If you want to remove a previously defined attribute from an element, you can set it to
null as in the example below:
<!-- Results in:<title></title><meta itemprop="name"><meta property="og:title"><meta name="twitter:title">-->
Note that neither Headful nor vue-headful add missing HTML elements, they only add attribute values. So it is important that you add everything that you want to have populated in your HTML first. For example, to specify the title and description you have to prepare the HTML as follows.
<!-- ... -->
vue-headful also supports dynamic properties (e.g.
:title="variableName") and adds watchers to everything.
That means you can also set head properties asynchronously, for example after an API request.
Also see the non-complete list of meta tags and other head properties you can define using vue-headful:
For more information on everything you can put into
<head>, have a look at https://gethead.info/.
vue-headful works with every current and most reasonably old web browsers. If you need to support older browsers including Internet Explorer, have a look at Headful: Compatibility.