转自:https://stackoverflow.com/questions/35835214/vue-js-failed-to-resolve-filter-key

I am following this tutorial https://laracasts.com/series/search-as-a-service/episodes/2 and got stuck on the following error

  1. [Vue warn]: Invalid expression. Generated function body: scope.keyup:scope.search
  2. [Vue warn]: Failed to resolve filter: key

shown in console.

This is the code.

  1. <input type="text" v-model="query" v-on="keyup: search | key 'enter'">
  2. <div class="results">
  3. <article v-for="movie in movies">
  4. <h2> @{{ movie.name }}</h2>
  5. <h4> @{{ movie.rating }}</h4>
  6. </article>
  7. </div>
  8. </div>
  9. <script src="http://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.17/vue.js"></script>
  11. <script>
  12. new Vue ({
  13. el: 'body',
  14. data: { query: '' , movies: [] },
  15. ready: function (){
  16. this.client = algoliasearch('AH9XU5726U', '58fd00912ce725b3f627cfa6cb8292ee');
  17. this.index = this.client.initIndex('getstarted_actors');
  18. },
  19. methods: {
  20. search: function () {
  21. this.index.search(this.query, function(error, results){
  22. this.movies = results.hits;
  23. }.bind(this));
  24. }
  25. }
  26. });
  27. </script>

Am I missing something? or is the tutorial outdated?

asked Mar 7 '16 at 2:23
Mike

242215
1
 
  1. v-on="keyup: search | key 'enter'"

is a old version declaration, change to this:

  1. v-on:keyup.enter="search"

http://vuejs.org/guide/events.html#Key_Modifiers

Vue.js Failed to resolve filter: key的更多相关文章

  1. vue 过滤器filters的使用以及常见报错小坑(Failed to resolve filter)

    今天使用vue 过滤器中发现一个小坑,网上查到的大都是不正确的解决方法,故分享给大家: 原错误代码: // 过滤器 filter:{ FdishList:function(value){ if (!v ...

  2. Vue.js报错Failed to resolve filter问题原因

    Vue.js报错Failed to resolve filter问题原因 金刚 vue Vue.js js javascript 之前使用vue.js写分页功能时,写了一个过滤器,发现一个比较奇怪的错 ...

  3. Failed to resolve filter报错原因

    问题 页面写过滤器,控制台报错,Failed to resolve filter 分析 语法错误?先检查 ``` {{ params | filterA }} filters: { filterA: ...

  4. electron-vue [Vue warn]: Failed to resolve directive: decorator

    electron-vue引入ant-desigin-vue使用ant自定义指令 v-decorator报销 <a-form-item> <a-input v-decorator=&q ...

  5. 解决IE报错[vue router]Failed to resolve async component default:strict 模式下不允许分配到只读属性

    之前遇到过一个奇怪的问题,在其他浏览器下一切正常,但在万恶的IE下,却一直不行. 具体问题场景就是:比如orderDetail页面出现问题,那么只要是路由跳转的,点第1次无法跳转,必须得点第2次才可以 ...

  6. 简单易懂的 Vue.js 基础知识 !

    根 vue 实例 let viewModel = new Vue({ // 包含数据.模板.挂载元素.方法.生命周期钩子等选项 }) Hello Wrold  <!-- 这是我们的 View - ...

  7. Vue自定义指令报错:Failed to resolve directive: xxx

    Vue自定义指令报错 Failed to resolve directive: modle 这个报错有2个原因: 1.指令单词拼错 2.Vue.directive() 这个方法没有写在 new Vue ...

  8. Vue.js 的几点总结Watchers/router key/render

    Vue.js 的几点总结,下面就是实战案例,一起来看一下. 第一招:化繁为简的Watchers 场景还原: 1 2 3 4 5 6 7 8 created(){   this.fetchPostLis ...

  9. Vue.js(2.x)之列表渲染(v-for/key)

    1.v-for是Vue里的循环语句,与其他语言的循环大同小异.首先得有需要循环且不为空的数组,循环的关键字为in或of. 需要索引时的写法: v-for里的in可以使用of代替: 还可以使用v-for ...

随机推荐

  1. 【支付专区】之微信支付构建请求参数xml

    /** * <p>Desc:weChat构建请求参数</p> * <p>参数名ASCII码从小到大排序(字典序)</p> * @param params ...

  2. 【JVM】Class结构之常量池

    常量池 主要包括下面2类: 字面量(Literal):如int,double,String等: 符号引用(Symbolic Reference): 符号引用 类和接口的全限定名: 字段的名称和描述符: ...

  3. gulp学习总结

    一.gulp使用-博客推荐: http://www.sheyilin.com/2016/02/gulp_introduce/ 二.gulp的作用 gulp是一个前端构建工具,它是一个工具框架,可以通过 ...

  4. 个人知识管理PKM:收集、消化、应用、创新

                                                          个人知识管理PKM:收集.消化.应用.创新 准备工作1.制作知识分类体系(在线博客分类.本地 ...

  5. php的方法

    字符串: strlen(): 字符串的个数: . : 通过.来进行字符串的拼接: 数组: count(): 数组的 个数: is_array(): 判断是不是一个数组: 实参的方法: func_num ...

  6. java 泛型 checkcast

    我们来看一段代码 public class Test3 { public static void main(String args[]) throws IllegalAccessException, ...

  7. phpStudy配置站点 解决You don't have permission to access / on this server

    1.配置站点:打开phpStudy->其他选项菜单->站点域名管理 2.配置站点:打开phpStudy->其他选项菜单->打开hosts 3.在apache的配置文件vhost ...

  8. T-SQL 事务

    use StudentManager go declare @errorSum int --定义变量,用于累计事务执行过程中的错误 --初始化为0,即无错误 begin transaction beg ...

  9. tf.assign,tf.assign_add,tf.assign_sub

    a = tf.Variable(0.0,dtype=tf.float32) with tf.Session() as sess: sess.run(tf.global_variables_initia ...

  10. 卷积神经网络之GoogleNet:inceptionV3模型学习

    Rethinking the Inception Architecture for Computer Vision 论文地址:https://arxiv.org/abs/1512.00567 Abst ...