[英]conditional rendering to display component in vue
我有一個父組件,其中的內容應該有條件地顯示
當userinput
變量為假時
應刪除<div class="parent">
並顯示 PopUp 組件
我只能用v-if else
改變單個元素
母公司
<template>
<div>
<button>x</button>
<p>errorMessage</p>
</div>
</template>
子組件 - PopUp
<template> <div> <button>x</button> <p>errorMessage</p> </div> </template>
添加v-if="userinput"
不起作用?
如果我明白你想要什么,你應該有這樣的東西:
// parent comp <template> <div> <h1>header</h1> <div v-if="userinput" class="parent"> <h2>infos</h2> <button>x</button> </div> <PopUp v-else/> </div> </template>
不要猶豫,閱讀Vue.js 文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.