测试Vue.js(^ 2.5。*)组件时如何处理有关prop变异的警告消息

时间:2019-02-07 10:22:41

标签: testing vue.js vuejs2

测试用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>

1 个答案:

答案 0 :(得分:3)

在安装要测试的组件时,为防止错误消息在控制台中显示,请将sync选项的false传递给mount函数。另请参见https://vue-test-utils.vuejs.org/api/options.html#sync