Vue入门之旅:一报错 Unknown ... make sure to provide the "name" option及error compiling template
报错一: Unknown custom element: <custom-select> - did you register the component correctly? For recursive components, make sure to provide the "name" option
代码:
html
<custom-select v-bind:list="list2"></custom-select>
js
new Vue({
el: "#app",
data:{
list1: [{"name":"beijing"}, {"name" : "hangzhou" }],
list2: ["2017-1-1", "2017-3-3"]
}
});
//<li class="match-list-li">'+value.name+'</li>
Vue.component("custom-select", {
data: function(){
return {
selectShow : false,
val: ""
};
},
props: ["list"],
template: `
<input type="text" class="form-control" placeholder='press "enter" to match the Employee'
@click="selectShow = !selectShow"
:value="val">
<match-list v-show="selectShow"
:list="list"
v-on:received="changeValueHandler"
></match-list>
`,
methods : {
//v-on:received 订阅事件
changeValueHandler(value){
this.val = value;
}
}
});
//child
Vue.component("match-list", {
props: ["list"],
template: `
<ul class="repo-admin-match">
<li class="match-list-li" v-for="item of list" @click="changeValueHandler(item)">{{item}}</li>
</ul>
`,
methods : {
changeValueHandler : function(name){
//在子组件中有交互
//告知父级 改变val 需发出一个自定义事件
this.$emit("received", name);
}
}
});
报错原因:
先新建了Vue(new Vue),然后注册组件(Vue.component) 。把顺序颠倒一下即可解决
------------------------------------
报错2:error compiling template
这个一般是写的不符合规范,不能被编译

--Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.大意应该是Component template应该包含一个确切存在的根元素
所以 我用<section class="wrap"></wrap>包裹起来
Vue入门之旅:一报错 Unknown ... make sure to provide the "name" option及error compiling template的更多相关文章
- scp使用加密算法报错unknown cipher type
为了提高scp的传输速度指定了scp的加密算法为arcfour $ scp -c arcfour localFile userName@remoteIP:remoteFile 得到报错unknown ...
- vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives
vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives Vue 2.2.0+的版本里,当在组件 ...
- jmeter------reponse报错”Unknown column 'XXXXX' in 'where clause'“
一.问题描述 jmeter添加了与数据库mysql的连接,编写完JDBC Request之后,运行提示报错”Unknown column 'be7f5b6e750bb6becf855386338644 ...
- springboot项目POM文件第一行报错 Unknown Error
改成 war 不错了,但是打包麻烦 pom 文件报错 UnKnown Error第一次碰到这个问题,花了几个小时才解决,除了UnKnown 没有任何提示.网上搜的大部分情况都不是我遇到的. 还是没有解 ...
- 使用spring boot 2.1.8生成的maven项目pom.xml第一行报错unknown error
问题:eclipse neon4.6.3新建springboot项目时pom.xml报错unknown error 原因: spring boot 2.1.8更新了maven插件,eclipse不兼容 ...
- vuex2 mapActions 报错 `unknown action type: xxxx`
export const setBreadCrumb = ({ dispatch }, data) => { dispatch('SET_BREADCRUMB', data) } 当调用的时候报 ...
- 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist
解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...
- springboot项目的maven的pom.xml文件第一行报错 Unknown Error
springboot项目的maven的pom.xml文件第一行报错 Unknown Error https://blog.csdn.net/mini_jike/article/details/9239 ...
- idea使用Vue的v-bind,v-on报错
参考解决在WebStorm中使用Vue的v-bind,v-on报错 File-->Settings-->Editor-->Inspections-->XML 把 Unbound ...
随机推荐
- php中数据类型自动转换
1.1 转为布尔型(即返回值为0) 空字符串''或"" 数字0或0.0 字符'0'或"0" 空值NULL 没有成员的数组 其余都转换成布尔型true,包含 ...
- phpexcel 读取日期的问题?
phpexcel 读取excel数字时,显示为一串数字(时间都是类似于这样的数字:41890.620138889),如何将数字转换为对应的日期来显示呢?特别是例如星期一这种的时间. 可以用phpexc ...
- PyCharm设置python新建文件指定编码为utf-8
PyCharm新建文件时可以在模板中添加编码字符集为utf-8,新建文件可自动添加了
- js 判断是否为mac电脑 、还是windows操作系统
/** * 是否为mac系统(包含iphone手机) * */ var isMac = function() { return /macintosh|mac os x/i.test(navigator ...
- python--getattr函数
getattr函数原型 getattr(object, name[, default]) -> value getattr是功能就是获取object对象的name属性的值(object.name ...
- mysql 查询锁,解锁语句
一:锁表: 锁定数据表,避免在备份过程中,表被更新 mysql>LOCK TABLES tbl_name READ; 为表增加一个写锁定: mysql>LOCK TABLES tbl_na ...
- Catalog的种类
框架中的Catalog 在MEF框架中,包含了4种Catalog,所有的Catalog的是从System.ComponentModel.Composition.Primitives名称空间下的Comp ...
- [ tarjan + dfs ] poj 2762 Going from u to v or from v to u?
题目链接: http://poj.org/problem?id=2762 Going from u to v or from v to u? Time Limit: 2000MS Memory L ...
- poj1703 Find them, Catch them(并查集的应用)
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 32225 Accepte ...
- layui基础上的tree菜单动态渲染;
var layout=[ { title:'脚本对象名称', treeNodes:true, headerClass:'value_col', colClass:'value_col', style: ...