[英]conditional rendering to display component in vue
I have a parent comp which content should be displayd conditionally我有一个父组件,其中的内容应该有条件地显示
when the userinput
variable is false当
userinput
变量为假时
The <div class="parent">
should be removed and the PopUp component displayed应删除
<div class="parent">
并显示 PopUp 组件
I could only change single elements with v-if else
我只能用
v-if else
改变单个元素
parent comp母公司
<template>
<div>
<button>x</button>
<p>errorMessage</p>
</div>
</template>
child component - PopUp子组件 - PopUp
<template> <div> <button>x</button> <p>errorMessage</p> </div> </template>
Add v-if="userinput"
doesn't work?添加
v-if="userinput"
不起作用?
If I understand what you want, you should have something like this:如果我明白你想要什么,你应该有这样的东西:
// 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>
Do not hesitate to read the Vue.js documentation不要犹豫,阅读Vue.js 文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.