容器里根据条件动态渲染不同的组件

<template>
  <div class="home-content">
    <component :is="componentVal"></component>
  </div>
</template>

<script>
import HomeOne from './test/HomeOne'
import HomeTwo from './test/HomeTwo'
import { ref } from 'vue'

export default {
  components: {
    HomeOne,
    HomeTwo
  },
  setup () {
    const componentVal = ref('HomeTwo')
    return {
      componentVal
    }
  }
}
</script>

<style>
</style>

 

posted @ 2021-02-01 16:01  栀夏。  阅读(131)  评论(0编辑  收藏  举报