Skip to content

Commit fe834f6

Browse files
committed
docs: add FAQ for "Vue warn: Failed setting prop"
1 parent e742510 commit fe834f6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/.vitepress/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export default defineConfig({
106106
}
107107
]
108108
},
109+
{
110+
text: 'FAQ',
111+
link: '/guide/faq/'
112+
},
109113
{
110114
text: 'Migrating from Vue 2',
111115
link: '/migration/'
@@ -214,6 +218,10 @@ export default defineConfig({
214218
}
215219
]
216220
},
221+
{
222+
text: 'FAQ',
223+
link: '/guide/faq/'
224+
},
217225
{
218226
text: 'Migrating from Vue 2',
219227
link: '/migration/'

docs/guide/faq/index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# FAQ
2+
3+
[[toc]]
4+
5+
## Vue warn: Failed setting prop
6+
7+
```
8+
[Vue warn]: Failed setting prop "prefix" on <component-stub>: value foo is invalid.
9+
TypeError: Cannot set property prefix of #<Element> which has only a getter
10+
```
11+
12+
This warning is shown in case you are using `shallowMount` or `stubs` with a property name that is shared with [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element).
13+
14+
Common property names that are shared with `Element`:
15+
* `attributes`
16+
* `children`
17+
* `prefix`
18+
19+
See: https://developer.mozilla.org/en-US/docs/Web/API/Element
20+
21+
**Possible solutions**
22+
23+
1. Use `mount` instead of `shallowMount` to render without stubs
24+
2. Ignore the warning by mocking `console.warn`
25+
3. Rename the prop to not clash with `Element` properties

0 commit comments

Comments
 (0)