在另一个组件中使用一个组件

时间:2020-11-05 11:34:57

标签: vue.js

我想根据条件在另一个组件中使用一个组件。

例如:

如果(条件为真){ 通话组件 }

有可能吗?

我尝试使用v-html,但没有用。

2 个答案:

答案 0 :(得分:0)

使用条件渲染。

<h1 v-if="awesome">Vue is awesome!</h1>
<h1 v-else>Oh no ?</h1>

Here,您可以找到更多详细信息

答案 1 :(得分:0)

v-if和导入组件?或尝试v-show

<div v-if='conditionIsTrue'> 
  <randomComponent /> 
</div>

<script>
import randomComponent from '@/components/component'

export default{
 components: {
  randomComponent
 }
}
</script>