0

我正在学习 Svelte,我想知道为什么单击事件在此示例中不起作用。我收到一条错误消息:

类型错误:每个值未定义'

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>
4

1 回答 1

1

看起来这是 1.56 中引入的错误 - 如果您将 URL 中的版本更改为 1.55,它可以工作。我们会把它修好。谢谢!

于 2018-03-05T22:37:10.530 回答