我正在学习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>