中等Vue
0 1

请解释:Vue的函数式组件 是什么?

【概念释义】

函数式组件是无状态、无实例(无 this)的组件,仅接收 props 渲染 UI,没有 data 与组件生命周期。Vue 2 设 functional: true;Vue 3 普通 SFC 无状态写法即可,性能差异已缩小。

【基础使用】

javascript
"qb-hl-comment">// Vue 2
export default {
  functional: true,
  props: ['label', 'value'],
  render(h, { props }) {
    return h('span', `${props.label}: ${props.value}`);
  },
};

登录查看完整 902

回答讨论

暂无讨论,登录后可抢先发言

本题库更多题目(50)