vue3传属性时报错 [Vue warn]: Component is missing template or render function.

上网查这个问题,解决方案很多,没有一款适合我。。。先说我的解决办法,如果解决不了再往下看,我的原因是 用的子组件的ref和子组件的标签名一样了:

<ChildComponent1
    ref="ChildComponent1"
    :parent-data="data"
  >
    <template #slot-content>
      <div>插槽 content 内容000000000</div>
    </template>
    <template #slot-footer>
      <div>插槽 footer 内容11111111</div>
    </template>
  </ChildComponent1>

在这里插入图片描述
给 ref 改个名字就好了。。。

使用技术:vue3+ts

用的props传值,本来都好好的,后来发现给一个子组件传值发生变化的时候,子组件展示有问题并且报警告:[Vue warn]: Component is missing template or render function

[Vue warn]: Component is missing template or render function

意思很明显,好像是我写了空白的缺少 template和script的组件,但问题是我组件内容是完整的啊:

<template>
  <div class=""> 组件1 </div>
</template>

<script lang="ts" setup>
  import { ref, reactive, defineEmits, onBeforeMount, onMounted } from 'vue';
  const data: any = reactive({});
</script>

<script lang="ts">
  export default {
    name: 'ChildComponent1',
    data() {
      return {};
    },
  };
</script>

<style lang="less" scoped></style>

如果你的问题不是这个,可以看看网上常见的别的解决办法:

  1. 子组件是空白的
  2. 子组件引入的时候没有写.vue
import ChildComponent1from './ChildComponent1';
// 改为
import ChildComponent1from './ChildComponent1.vue';

希望本文对您有所帮助!

  • 18
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值