From fe834f6863e8627b4306e0742f322c55fd4943c1 Mon Sep 17 00:00:00 2001 From: freakzlike Date: Sat, 20 May 2023 09:24:29 +0200 Subject: [PATCH] docs: add FAQ for "Vue warn: Failed setting prop" --- docs/.vitepress/config.ts | 8 ++++++++ docs/guide/faq/index.md | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/guide/faq/index.md diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 100ee81e4..46c46d4e7 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -106,6 +106,10 @@ export default defineConfig({ } ] }, + { + text: 'FAQ', + link: '/guide/faq/' + }, { text: 'Migrating from Vue 2', link: '/migration/' @@ -214,6 +218,10 @@ export default defineConfig({ } ] }, + { + text: 'FAQ', + link: '/guide/faq/' + }, { text: 'Migrating from Vue 2', link: '/migration/' diff --git a/docs/guide/faq/index.md b/docs/guide/faq/index.md new file mode 100644 index 000000000..1c883cab8 --- /dev/null +++ b/docs/guide/faq/index.md @@ -0,0 +1,25 @@ +# FAQ + +[[toc]] + +## Vue warn: Failed setting prop + +``` +[Vue warn]: Failed setting prop "prefix" on : value foo is invalid. +TypeError: Cannot set property prefix of # which has only a getter +``` + +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). + +Common property names that are shared with `Element`: +* `attributes` +* `children` +* `prefix` + +See: https://developer.mozilla.org/en-US/docs/Web/API/Element + +**Possible solutions** + +1. Use `mount` instead of `shallowMount` to render without stubs +2. Ignore the warning by mocking `console.warn` +3. Rename the prop to not clash with `Element` properties