Vue Tip: Change the Interpolation Delimiter
It is possible to adjust the delimiters used for text interpolation within the template to avoid conflicting with server-side frameworks that also use mustache syntax.
Category · 43 articles
Articles in the category Template.
It is possible to adjust the delimiters used for text interpolation within the template to avoid conflicting with server-side frameworks that also use mustache syntax.
When using Vue from a CDN, no "build step" is involved. This makes the setup much more straightforward and is suitable for enhancing static HTML or integrating with a backend framework.
Web Components is an umbrella term for a set of web native APIs that allows developers to create reusable custom elements. Vue has excellent support for both consuming and creating custom elements.
Components using script setup are closed by default and will not expose any of the bindings declared inside script setup.
Third-party components are often wrapped in a custom component. But in that way, the slots of the third-party component get lost.
Template refs only exist after the component is mounted. Thus, it’s necessary to type template refs with a union type that includes the DOM element type as well as null.
In addition to the default set of directives like v-model or v-show, you can also register your own custom directives.
It is a no-go to manipulate the DOM in Vue.js directly. Instead, you should use the "ref" attribute.
Vue provides an object that can be used to register global properties that can be accessed on any component instance inside the application.
v-if has higher toggle costs while v-show has higher initial render costs.
There are many situations when you need to conditionally display multiple Vue components. To avoid "empty" wrappers you should use not use HTML tags.
Eager delay spinners are not a good user experience. They can make a snappy user interface feel slower. We want delay spinners to appear only after a perceivable delay.
You can check if a slot is empty, for example, only to render it if it has content.
The v-memo directive is like a computed prop for the template.
A 'fallthrough attribute' is an attribute or v-on event listener that is passed to a component, but is not explicitly declared in the receiving component's props or emits. Common examples of this include class, style, and id attributes.
There are cases when it's useful to specify fallback (i.e. default) content for a slot, to be rendered only when no content is provided.
It's possible to use optional chaining in Vue templates.
The double mustaches interpret the data as plain text, not HTML. To output real HTML, you will need to use the v-html directive.
With teleport, you can render a component in a different place in the DOM tree, even if this place is not in your app's scope.
Vue component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods.