例子:利用带有 v-for 的 <template> 来循环渲染一段包含多个元素的内容。比如:在template使用v-for可以减少页面的节点,循环后的结果是没有ul标签的 

Vue template  VS  React Fragments

例子: v-if 使用 template 切换多个元素

Vue template  VS  React Fragments

 

React Fragments:

其实和vue差不多,不过react没有指令的概念

Vue template  VS  React Fragments   Vue template  VS  React Fragments

带Key key, 是唯一可以传递给 Fragment 的属性 ( vue 不能再 template 上使用 key )

Vue template  VS  React Fragments

 

 

  注意: vue 的 .vue 的模板,跟节点只能有一个,React 的render 函数返回的 JSX 可以包含多个节点

 

相关文章: