Vue.js disable blank comments

69
May 30, 2021, at 11:40 PM

Usually, when Vue.js hides an element through v-if, a comment is left in its place.

Vue file:

<div v-if="true">Hello</div>
<div v-if="false">world</div>

Output:

<div v-if="true">Hello</div>
<!--  -->

Is it possible to disable appearance of this comment?

Desired output:

<div v-if="true">Hello</div>
Answer 1

There is an issue in the vuejs repo. one of the comments that I think would be useful says:

v-if is usually used for elements in a relatively stable node structure, rendering it to empty comment tags makes vnode lists diffing more efficient as the lists are more "stable", and it avoids some edge cases when elements are not keyed. In your case it doesn't seem to cause any real issue other than small inspection annoyance, so unfortunately I don't think we would change this behavior.

For virtual scrolling lists, it maybe a better idea to use a computed property to return a subset of the items that needs to be rendered, e.g. v-for="item in displayedItems" instead of using a v-if on each item.

READ ALSO
How do I get the correct value in dataframe while webscraping?

How do I get the correct value in dataframe while webscraping?

I am trying to get value from websraping however, I am not able to construct correct class for the value

42
Delete Multiple DB rows and Images with Same title

Delete Multiple DB rows and Images with Same title

I am trying to delete multiple rows based on 'slug' column using CodeigniterForm DB all rows are deleted but the problem is with Images

56
Click count using JavaScript for many buttons with default value &#39;0&#39;

Click count using JavaScript for many buttons with default value '0'

I want to use a click count function in JavaScript to measure the number of clicks on a button in otreeThe data should be stored in the database using a hidden input field

89
Django login error, LOGIN_REDIRECT_URL is not working

Django login error, LOGIN_REDIRECT_URL is not working

When I click the login button the next page shows HTTP ERROR 405

96