Within my HTML, I have implemented conditional rendering using v-if
<div v-if="showdiv">
<p>Content 1 appears here</p>
</div>
<div v-if="!showdiv">
<p>Content 2 appears here</p>
</div>
My data variable is set up as follows:
data() {
render {
showdiv: ''
}
}
There is an API that determines whether showdiv should be true or false. However, if the API response is slow, I want showdiv to be null so that neither div is displayed. Unfortunately, showdiv is being interpreted as false in such cases and the second div is shown.
<div v-if="!showdiv">
<p>Content 2 appears here</p>
</div>
I want to only display the div when showdiv is true or false. If its value is null, I do not want any div to be rendered. What steps can I take to achieve this desired behavior?