Skip to content

built-in commands

Built-in commands handle control flow, display switching, text, and forms in templates.

CommandPurpose
v-if / v-else-if / v-elseConditional rendering
v-forList rendering
v-showdisplay switch
v-modelTwo-way binding of forms and components
v-textSet text
v-htmlSet HTML
v-onceRender only once
v-memoSkip updates by dependency

Example

html
<p v-if="loading">加载中</p>

<li v-for="item in items" :key="item.id">{{ item.name }}</li>

<section v-show="open">内容</section>

TIP

It is recommended to put complex expressions into TypeScript variables or useComputed() in advance so that the template remains readable.