vue render函数 怎么渲染循环的数据

js代码如下:

        const h = this.$createElement;
        h("p", null, [
        h("span", null, "是否删除配置  "),
        h("i", { style: "color: #E6A23C" }, `${names}.join(",")`)
        ]),
        "提示",
        {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
        }
        )

names是代表姓名的一个数组,我现在想将其循环渲染,请问用render如何实现?

阅读 5.6k
3 个回答
createElement(MyComponent, { props: { someProp: 'foobar' } })

其中MyComponent可以是vue组件,你把循环渲染的需求放到组件中就行了。
不过, 用jsx更简洁,先得需要babel-plugin-transform-vue-jsx插件,就可以舒服些了

少侠,这就是js啊。for循环你看OK吗?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题