报错一: 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的更多相关文章

  1. scp使用加密算法报错unknown cipher type

    为了提高scp的传输速度指定了scp的加密算法为arcfour $ scp -c arcfour localFile userName@remoteIP:remoteFile 得到报错unknown ...

  2. 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+的版本里,当在组件 ...

  3. jmeter------reponse报错”Unknown column 'XXXXX' in 'where clause'“

    一.问题描述 jmeter添加了与数据库mysql的连接,编写完JDBC Request之后,运行提示报错”Unknown column 'be7f5b6e750bb6becf855386338644 ...

  4. springboot项目POM文件第一行报错 Unknown Error

    改成 war 不错了,但是打包麻烦 pom 文件报错 UnKnown Error第一次碰到这个问题,花了几个小时才解决,除了UnKnown 没有任何提示.网上搜的大部分情况都不是我遇到的. 还是没有解 ...

  5. 使用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不兼容 ...

  6. vuex2 mapActions 报错 `unknown action type: xxxx`

    export const setBreadCrumb = ({ dispatch }, data) => { dispatch('SET_BREADCRUMB', data) } 当调用的时候报 ...

  7. 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist

    解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...

  8. springboot项目的maven的pom.xml文件第一行报错 Unknown Error

    springboot项目的maven的pom.xml文件第一行报错 Unknown Error https://blog.csdn.net/mini_jike/article/details/9239 ...

  9. idea使用Vue的v-bind,v-on报错

    参考解决在WebStorm中使用Vue的v-bind,v-on报错 File-->Settings-->Editor-->Inspections-->XML 把 Unbound ...

随机推荐

  1. unity3d通过代码动态创建销毁游戏对象

    只能动态创建内部提供的游戏对象,代码如下: //按下C后创建 if (Input.GetKeyDown (KeyCode.C)) { GameObject s1 = GameObject.Create ...

  2. 怎样防止应用因获取IDFA被AppStore拒绝

    由于Appstore禁止不使用广告而採集IDFA的app上架,友盟提供IDFA版和不含IDFA版两个SDK,两个SDK在数据上并没有差异.採集IDFA是为了防止今后由于苹果可能禁止眼下使用的openu ...

  3. python DataFrame获取行数、列数、索引及第几行第几列的值

    print df.columns.size#列数 2 print df.iloc[:,0].size#行数 3 print df.ix[[0]].index.values[0]#索引值 0 print ...

  4. wpf 帧动画

    帧动画实现很简单 <ImageBrush x:Key="speed_s" Stretch="Fill" ImageSource="/images ...

  5. Docker使用Dockerfile创建支持ssh服务自启动的容器镜像

    原文链接:Docker使用Dockerfile创建支持ssh服务自启动的容器镜像 1. 首先创建一个Dockerfile文件.文件内容例如以下 # 选择一个已有的os镜像作为基础 FROM cento ...

  6. Unable to verify your data submission错误解决

    如果不用Yii2提供的ActiveForm组件生成表单,而是自定义表单,那么当你提交表单的时候就会报这个错误 Unable to verify your data submission 这是因为Web ...

  7. linux下批量替换文件内容(转)

    http://www.cnblogs.com/end/archive/2012/05/24/2517131.html 1.网络上现成的资料 格式: sed -i "s/查找字段/替换字段/g ...

  8. ubuntu 安装python3.5

    wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz xz -d Python-.tar.xz .tar cd Python ...

  9. JVM日志和参数的理解

    写这篇wiki的目的:最近在调整Hbase的JVM,翻了些文档和wiki,想写点东西,给自己和想了解jvm日志和参数的同 学提供些帮助. 一:理解GC日志格式,读GC日志的方法 1:开启日志 -ver ...

  10. vim插件管理器的安装和配置-windows

    # vim插件管理器的安装和配置-windows ### 前言------------------------------ vim做一框功能强大的编辑器,扩展功能令人称奇,插件机制非常灵活- 本篇推荐 ...