事件计算属性问题

时间:2018-03-05 20:45:58

标签: svelte

我正在学习Svelte,我想知道为什么click事件在这个例子中不起作用。我收到一条错误消息:

  

TypeError:each_value未定义'

https://svelte.technology/repl?version=1.56.1&gist=798be31e79dfbf363a9f7e497557acfb

<p><input bind:value=search></p>

{{#each categories.filter(predicate) as category}}
  <!-- the click event should work, right? -->
    <button on:click='console.log(category)'>{{category}}</button>
{{/each}}

<script>
    export default {
        data() {
            return {
                search: '',
                categories: [
                    'animal',
                    'vegetable',
                    'mineral'
                ]
            }
        },
      computed: {
            predicate: search => {
                search = search.toLowerCase();
                return word => word.startsWith(search);
            }
        }
    };
</script>

1 个答案:

答案 0 :(得分:0)

看起来这是1.56中引入的错误 - 如果你change the version in the URL to 1.55,它可以正常工作。我们会修复它。谢谢!