laravel Vue.js 无法解析过滤器:key

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35835214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:21:27  来源:igfitidea点击:

Vue.js Failed to resolve filter: key

javascriptlaravelvue.jsalgolia

提问by Mike

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

我正在关注本教程https://laracasts.com/series/search-as-a-service/episodes/2并陷入以下错误

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

shown in console.

显示在控制台中。

This is the code.

这是代码。

<input type="text" v-model="query" v-on="keyup: search | key 'enter'">
    <div class="results">
        <article v-for="movie in movies">
            <h2> @{{ movie.name  }}</h2>
            <h4> @{{ movie.rating  }}</h4>
        </article>
    </div>
</div>

    <script src="http://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.17/vue.js"></script>
    <script>
        new Vue ({
            el: 'body',
            data: { query: '' , movies: [] },


            ready: function (){
                this.client = algoliasearch('AH9XU5726U', '58fd00912ce725b3f627cfa6cb8292ee');
                this.index = this.client.initIndex('getstarted_actors');
            },
            methods: {
                search: function () {
                    this.index.search(this.query, function(error, results){
                        this.movies = results.hits;
                    }.bind(this));
                }
            }

        });
    </script>

Am I missing something? or is the tutorial outdated?

我错过了什么吗?还是教程过时了?

采纳答案by Ion

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

is a old version declaration, change to this:

是旧版本的声明,改成这样:

v-on:keyup.enter="search"

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

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