FAQ
- 设置日期与计时器与
vitest Vue警告: 设置Props失败
设置日期与计时器与vitest
Vue的调度器取决于系统时间。确保在调用vi.setSystemTime之后挂载组件,因为Vue取决于它的副作用。在调用vi.setSystemTime之前安装组件可能会导致反应中断。
Vue 警告: 设置Props失败
bash
[Vue warn]: Failed setting prop "prefix" on <component-stub>: value foo is invalid.
TypeError: Cannot set property prefix of #<Element> which has only a getter[Vue warn]: Failed setting prop "prefix" on <component-stub>: value foo is invalid.
TypeError: Cannot set property prefix of #<Element> which has only a getter如果您使用的是与Element共享属性名的shallowMount或stub,则会显示此警告。
与Element共享的通用属性名:
attributeschildrenprefix
查看 https://developer.mozilla.org/en-US/docs/Web/API/Element
可能的解决方案
- 使用
mount而不是shallowMount来渲染无存根 - 通过模拟
console.warn来忽略警告 - 重命名该道具以避免与元素属性冲突
zerone