0

i'm using render with vue.js and iview, today when i use it, i find it doesn't work

{
  title: 'title1',
  key: 'order',
  render:(h, params) => params.index + 1
}

then I try to use it in another way, it works.

{
  title: 'title1',
  key: 'order',
  render:(h,params) => h('span', params.index + 1)
}

but the first way used to work days ago, i don't know why how can i make the first way available?

1 Answer 1

2

The first parameter in the render function h which is nothing but a function usually called createElement which contains information describing to Vue what kind of node it should render on the page.

This createElement takes 3 arguments:

  1. The HTML tag name. This is required.
  2. An object contains the attributes you pass in normal template. This is optional.
  3. Children nodes as an array or a simple text node as a string. This is optional.

You did not return the h function ,since the first argument is required and not provided in your first snippet of code, it did not work.

Reference - Render functions

To make your first snippet of code to work you to return the h function with the 1st argument any tag name like you are doing in the second snippet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.