簡體   English   中英

條件渲染以在vue中顯示組件

[英]conditional rendering to display component in vue

我有一個父組件,其中的內容應該有條件地顯示

userinput變量為假時
應刪除<div class="parent">並顯示 PopUp 組件


我嘗試使用 `v-if` 但不知道如何刪除整個 div 元素

我只能用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM