Why does react need the key attribute to identify elements, but vue does not? Which method does vue use to identify elements?
<ul>
<li key="2015">Duke</li>
<li key="2016">Villanova</li>
</ul>
<ul>
<li key="2014">Connecticut</li>
<li key="2015">Duke</li>
<li key="2016">Villanova</li>
</ul>
阿神2017-06-26 10:57:21
Who said vue has no key.
Whether it is vue or react, the key plays the same role. React does not need it, it just reports a warning.
大家讲道理2017-06-26 10:57:21
Vue also needs it, the official website reads: In order to give Vue a hint so that it can track the identity of each node and thus reuse and reorder existing elements, you need to provide a unique key attribute for each item. The ideal key value is that each item has a unique id. Link the key in vue
PHP中文网2017-06-26 10:57:21
Each corresponding unique key, so that react can know which key data you are operating on later, and you can update only this one