mirror of https://github.com/sveltejs/svelte
parent
c7ac8b82ba
commit
fa65f7af60
@ -0,0 +1,11 @@
|
||||
{{foo()}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
helpers: {
|
||||
foo () {
|
||||
return Math.random();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "Helpers should be pure functions, with at least one argument",
|
||||
"pos": 54,
|
||||
"loc": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "Helpers should be pure functions — they do not have access to the component instance and cannot use 'this'. Did you mean to put this in 'methods'?",
|
||||
"pos": 74,
|
||||
"loc": {
|
||||
"line": 7,
|
||||
"column": 11
|
||||
}
|
||||
}]
|
@ -0,0 +1,11 @@
|
||||
{{foo()}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
helpers: {
|
||||
foo () {
|
||||
return this.get( 'bar' );
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,13 @@
|
||||
{{sum(1, 2, 3)}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
helpers: {
|
||||
sum () {
|
||||
var total = '';
|
||||
for ( var i = 0; i < arguments.length; i += 1 ) total += arguments[i];
|
||||
return total;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in new issue