template or render function not defined.
template or render function not defined.
下午写 Vue $parent 实例时,总是遇到这个问题,不禁让人陷入沉思

Vue,醒醒啊,你怎么了,贴上子组件源代码
<template>
<div>
<child-component1></child-component1>
<child-component2></child-component2>
<button v-on:click="showChildComponentData">显示子组件的数据</button>
</div>
</template>
<script>
export default{
components: {
'child-component1': {
template: '#child-component1',
data: function () {
return {
msg: 'child component 111111'
}
}
},
'child-component2': {
template: '#child-component2',
data: function () {
return {
msg: 'child component 222222'
}
}
}
},
methods: {
showChildComponentData: function () {
for (var i = 0; i < this.$children.length; i++) {
alert(this.$children[i].msg)
}
}
}
}
</script>
这是报错信息:

修改后的代码:
<template>
<div>
<child-component1></child-component1>
<child-component2></child-component2>
<button v-on:click="showChildComponentData">显示子组件的数据</button>
</div>
</template>
<script>
export default{
components: {
'child-component1': {
template: '<p>I am ok</p>',
data: function () {
return {
msg: 'child component 111111'
}
}
},
'child-component2': {
template: '<p>ok</p>',
data: function () {
return {
msg: 'child component 222222'
}
}
}
},
methods: {
showChildComponentData: function () {
for (var i = 0; i < this.$children.length; i++) {
alert(this.$children[i].msg)
}
}
}
}
</script>
这样就好了,原因是 Vue 的构建,运行时构建删除了模板编译的功能,因此无法支持带 template 属性的 Vue 实例选项。
template or render function not defined.的更多相关文章
- template or render function not defined vue 突然报错了,怎么解决
报错图例如下:template or render function not defined vue 突然报错了,怎么解决什么错误呢,就是加载不出来,网上看了一通,是vue版本不对,是vue-comp ...
- Failed to mount component: template or render function not defined.
Failed to mount component: template or render function not defined. vue-loader13.0有一个变更就是默认启用了esModu ...
- "[Vue warn]: Failed to mount component: template or render function not defined"错误的解决
VUE中动态路由出错: vue.esm.js?a026: [Vue warn]: Failed to mount component: template or render function not ...
- [Vue warn]: Failed to mount component: template or render function not defined. 错误解决方法
解决方法import Vue from "vue"; 默认引入的文件是 vue/dist/vue.runtime.common.js.这个可以在node_modules/vue/p ...
- [Vue warn]: Failed to mount component: template or render function not defined.解决方案
命名视图 vue router 里有一个 模式叫做 命名视图 本来一个页面里面只能有一个路由视图 对应 一个组件,现在可以多个路由视图 对应 多个组件. 出错点 点击标签之后,<router-v ...
- [Vue warn]: Failed to mount component: template or render function not defined. found in ---> <XFbwz> at src/views/XFbwz.vue <App> at src/App.vue <Root>
1.引入.vue文件忘记加.vue 2.引入文件内容为空
- [Vue @Component] Control Template Contents with Vue's Render Function
Declaring templates and elements inside of templates works great for most scenarios. Sometimes you n ...
- [AngularJS] ngModelController render function
ModelValue and ViewValue: $viewValue: Actual string value in the view. $modelValue: The value in the ...
- vue实例属性之el,template,render
一.el,template,render属性优先性当Vue选项对象中有render渲染函数时,Vue构造函数将直接使用渲染函数渲染DOM树,当选项对象中没有render渲染函数时,Vue构造函数首先通 ...
随机推荐
- (2)MyEclipse怎么关联本地Tomcat服务器
1,在MyEclipse中点击服务器按钮: 2,选择“Configure Server” 3,在弹出面板中选择 [Servers]-[Tomcat]-[对应版本的服务器] 5,看上图,先选择Enabl ...
- +Java中的native关键字浅析(Java+Native+Interface)++
JNI是Java Native Interface的 缩写.从Java 1.1开始,Java Native Interface (JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的 ...
- ubuntu12.04安装tftp,配置,修改目录,错误类型
[前言]学习嵌入式,需要配置tftp服务,在网上搜了搜,很多,但是配置了,我的老是出现Error code 1: File not found错误,经过探索和一个大哥的博客http://blog.cs ...
- 比特币交易(Transaction)的输入与输出
比特币通过“挖矿”机制保证了不能任意造币.通过分布式网络和HashCash机制解决双重支付问题.事实上比特币系统中不存在独立的电子货币,而只存在交易单(账单),货币值是依附于交易单存在的,所以比特币中 ...
- Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(VSM)
Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(V 时间:2010-04-12 16:06来源:SilverlightChina. ...
- I.MX6 su.c 测试
/************************************************************************* * I.MX6 su.c 测试 * 说明: * 今 ...
- Linux网络协议栈(四)——链路层(2)
2.协议相关2.1.第3层协议的管理在Linux内核中,有两种不同目的的3层协议:(1) ptype_all管理的协议主要用于分析目的,它接收所有到达第3层协议的数据包.(2) ptype ...
- 我为什么要学习C++反汇编
写在开始 从6月7日开始到今天已经有5天了,在这5天的业余时间(工作之余)里终于系统的完成了C++反汇编的大部分问题的学习,今天写篇总结,算是对这几天学习的总结. 首先我想说明的一个问题就是我为什么要 ...
- bzoj 4711 小奇挖矿 —— 树形DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4711 就是树形DP,然而也想了半天才把转移想清楚: f[x][j][0] 表示 x 去上面 ...
- Extjs 3 Grid相关操作
extjs gridpanel 操作行 得到选中行的列 var model = grid.getSelectionModel(); model.selectAll(); //选择所有行 mod ...