V-if 组件不渲染dom节点


If you want the DOM still exists, using v-show.

v-show is like setting CSS display to none. So the DOM still exists, but you can’t see it.
v-if is like using javascript to set element to remove from tree that you specified.


thanks for reply,but in my project,i need to use “v-if”,because i have to prepare the data which used by the “tool” component in an async function,if i use v-show to render the “tool” component,it would cause complex problem

因為你給的資訊太少了 不過如果是async的問題 可以用這種方式解掉 不一定要註冊在tool上面

<template v-if="asyncLoadingComplete">
  <tool v-show=""></tool>

async loading() {
  this.asyncLoadingComplete = false;
  const res = await axios.get('/todo');
  this.asyncLoadingComplete = true;