Get the App
SLTechnology News&Howtos  ›  Development  › 

How vuejs dynamically changes title

Shulou Source: shulou.com Published: 2022-06-03 09:47:32 11月15日 Update

This article mainly shows you "how vuejs dynamically changes title", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how vuejs dynamically changes title" this article.

Dynamically change the title method: 1, in the "main.js" in the use of "document.title=el.dataset.title" to configure the browser title; 2, in the page tag, add "v-title data-title=" title value "" code can be dynamically changed.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Dynamically modify the page title in the Vue project

In main.js:

/ / set browser title Vue.directive ('title', {inserted: function (el, binding) {document.title = el.dataset.title}})

On the largest div of a page:

Add the following code:

V-title data-title= "Test title"

Effect:

The above is all the content of the article "how vuejs dynamically changes title". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Dynamic content articles pages code title browser learning help browsing maximum effect tutorials methods easy to understand more organization tags environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Microsoft Linux Docker Apple