v-if 最基本的条件渲染 <h1 v-if="awesome">Vue is awesome!</h1> if-else的渲染 <h1 v-if="awesome">Vue is awesome!</h1> <h1 v-else>Oh no ??</h1> 注:v-else 元素必须紧跟在带 v-if 或者 v-else-if 的元素的后面,否则它将不会被识别。 v-else-if <div v-if="type === ‘A‘"> A </div> <div v-else-if="type === ‘B‘"> B </div> <div v-else-if="type === ‘C‘"> C </div> <div v-else> Not A/B/C </div> 渲染分组 <template v-if="ok"> <h1>Title</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </template>
原文:https://www.cnblogs.com/xqxacm/p/12311907.html