我试图在Vue条件下使用窗口对象:
<li v-if="window.SpeechRecognition || window.webkitSpeechRecognition">
<a href="#">Voice</a>
</li>
但我得到了以下错误:
[Vue warn]: Property or method "window" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
如果用户的浏览器支持函数SpeechRecognition
,我如何解决这个错误并仅显示HTML元素?