uniapp:[Vue warn]: Failed to mount component: template or render function not de

457 阅读1分钟

在uniapp 项目中,自定义组件,引入并使用自定义组件时出现了该报错, 在这里插入图片描述 解决方案: 当我仔细检查,原来是自定义组件时,命名时将"="等于号写成了":"冒号. 在这里插入图片描述

创建自定义组件

<template name="组件名称"> 
	<view>这是一个自定义组件</view> 
</template> 
<script> 
    export default { 
        name: "组件名称", 
        //属性 
        props: { 	
            属性名称: { 		
                type: String, 
                value: "值" 	
            }
        }            
} 
</script> 
<style> 
</style> 

使用组件


<template>
	<view >
		<组件名称 组件属性="对应的值"></组件名称>
	</view>
</template>

<script>
import 组件名称 from "../../components/组件名.vue";
export default{
	components:{
		组件名称
	},
}
</script>

<style>
	
</style>