<>t>v-for Directive(无论该代码如何)的模板代码在收集的<>>>>>>>>每一项目上均已执行<><>><>>>>>>>><>t/sup>/em>> > >。
So when settings.pressure
is an empty array ([]
) it runs the template code once for each item in the array: 0 times!
But when you run settings.pressure[0].value
outside of v-for
and settings.pressure
is empty, the code tries to find the first item in settings.pressure
(which is undefined
). And then it tries to access the .value
of undefined
, like it was an object. Whenever you try to access any property of null
or undefined
, JavaScript will throw an error telling you they don t have any properties (because they can t have them, by design) and therefore they can t be queried for properties.
<<><>><>>><>>>>>>>>>>>>>>>---------------->-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------