testing - 测试 Vue.js (^2.5.*) 组件时如何处理有关 prop 发生突变的警告消息
问题描述
在测试使用 Vue utils 安装的组件时,我遇到以下错误消息:
Avoid mutating a prop directly since the value will be overwritten
whenever the parent component re-renders.
Instead, use a data or computed property based on the prop's value. Prop being mutated: <prop name>
解决方案
挂载要测试的组件时,为防止错误消息显示在控制台中,请将sync
选项传递给 false 给mount
函数。另请参阅https://vue-test-utils.vuejs.org/api/options.html#sync
推荐阅读
- javascript - 如何存储提示中的答案并使用它?
- visual-studio-code - VSCode Extension 执行本地 python (bash) 代码并附加到输出通道
- swift - 是否可以更改视图的 y 位置以获得更小的屏幕尺寸?
- pyspark - 如何在 Spark SQL 中访问 python 变量?
- javascript - JavaScript 提升 - 内存创建阶段后提升的代码
- flutter - Flutter GoogleMaps SearchMapPlaceWidget 此代码不会将相机动画到所选位置
- python - 一旦到达条件块内,如何打破条件语句并转到 elif/else?
- swift - 日期对象的创建是否接受时区参数?
- python - 相同模型实例的 Django 集合
- unit-testing - Kubernetes Fake Client 不处理 ObjectMeta 中的 GenerateName