FrontendDeveloper.in

Vue.js question detail

What is the purpose of vuejs once directive?

If you want to render a lot of static content then you need to make sure it only evaluated once and then cached thereafter. In this case, you can use v-once directive by wrapping at the root level.

The example usage of v-once directive would be as below,

Vue.component('legal-terms', {
template: `
<h1>Legal Terms</h1>
... a lot of static content goes here...
`
})

Note: It is recommended not to overuse unless there is slow rendering due to lot of static content.

Back to all Vue.js questions
Get LinkedIn Premium at Rs 399