0

我正在弄清楚如何在组件中呈现多个根元素,功能组件是解决方案,对我来说一切正常,但不确定如何呈现嵌套元素。

请检查comment我描述了什么对我有用的代码。

export default {
  name: 'MyFnlComp',
  functional: true,
  render(createElement, { props }) {
    const itemIndex = props.item.index;
    const nestedEle = createElement('div', {}, 'nested element goes here');

    const catCard = createElement('div', {}, nestedEle); // this doesn't work :(
    const userCards = createElement('div', {}, 'Hey! this works'); // this works :)

    return [catCard, userCards];
  },

};
4

1 回答 1

2

的最后一个参数createElement应该是字符串或数组..

const catCard = createElement('div', {}, [nestedEle]);
于 2020-03-14T18:16:37.980 回答