Skip to content

Commit 6c496dc

Browse files
committed
docs: update example
1 parent 391ed02 commit 6c496dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/rules/no-literals-in-template.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ description: disallow object, array, and function literals in template
1515

1616
This rule disallows object, array, and function literals in template `v-bind` directives.
1717
These literals are created as new references on every rerender, which can cause the child component's watchers to trigger unnecessarily even when the object hasn't actually changed.
18+
1819
If the literal references a variable from a `v-for` directive or a scoped slot, it is ignored.
1920

2021
<eslint-code-block :rules="{'vue/no-literals-in-template': ['error']}">
@@ -31,13 +32,16 @@ If the literal references a variable from a `v-for` directive or a scoped slot,
3132
<div :style="{ color: 'red' }" />
3233
3334
<template v-for="i in arr">
34-
<MyComponent :callback="() => someFunction(someArgs, i)" />
35+
<MyComponent :data="[i]" />
3536
<MyComponent :data="{ index: i }" />
37+
<MyComponent :callback="() => someFunction(someArgs, i)" />
3638
</template>
3739
3840
<Child>
3941
<template #default="{ foo }">
42+
<MyComponent :data="[foo]" />
4043
<MyComponent :data="{ val: foo }" />
44+
<MyComponent :data="() => someFunction(someArgs, foo)" />
4145
</template>
4246
</Child>
4347
@@ -50,13 +54,16 @@ If the literal references a variable from a `v-for` directive or a scoped slot,
5054
<div :callback="function() { return 1 }" />
5155
5256
<template v-for="i in arr">
53-
<MyComponent :callback="() => someFunction(someArgs, globalVars)" />
57+
<MyComponent :data="[globalVars]" />
5458
<MyComponent :data="{ index: globalVars }" />
59+
<MyComponent :callback="() => someFunction(someArgs, globalVars)" />
5560
</template>
5661
5762
<Child>
5863
<template #default="{ foo }">
64+
<MyComponent :data="[globalVars]" />
5965
<MyComponent :data="{ val: globalVars }" />
66+
<MyComponent :data="() => someFunction(someArgs, globalVars)" />
6067
</template>
6168
</Child>
6269
</template>

0 commit comments

Comments
 (0)