uniapp:[Vue warn]: Failed to mount component: template or render function not defined. found in

简介: uniapp:[Vue warn]: Failed to mount component: template or render function not defined. found in

在uniapp 项目中,自定义组件,引入并使用自定义组件时出现了该报错,

image.png

解决方案:

当我仔细检查,原来是自定义组件时,命名时将"=“等于号写成了”:"冒号.

image.png


创建自定义组件

<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>
相关文章
|
JavaScript
报错[Vue warn]: $listeners is readonly. $attrs is readonly.怎么解决?
报错[Vue warn]: $listeners is readonly. $attrs is readonly.怎么解决?
|
JavaScript 小程序 前端开发
[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on st
[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on st
362 0
|
9月前
|
iOS开发 开发者
uniapp开发ios打包Error code = -5000 Error message: Error: certificate file(p12) import failed!报错问题如何解决
uniapp开发ios打包Error code = -5000 Error message: Error: certificate file(p12) import failed!报错问题如何解决
497 67
uniapp开发ios打包Error code = -5000 Error message: Error: certificate file(p12) import failed!报错问题如何解决
|
存储 自然语言处理 JavaScript
vue中template到VDOM发生了什么
vue中template到VDOM发生了什么
vue中template到VDOM发生了什么
|
JavaScript 索引
Component name “index“ should always be multi-word vue/multi-word-component-names
Component name “index“ should always be multi-word vue/multi-word-component-names
|
JavaScript
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
1025 1
|
JavaScript
vue 动态组件【详解】component :is
vue 动态组件【详解】component :is
592 0
|
JavaScript 前端开发 编译器
Vue组件(Component)
Vue组件(Component)
179 3
Vue3 使用动态组件 component
Vue3 使用动态组件 component
473 0

热门文章

最新文章