vue iview table render 渲染失效

table中render button没有渲染出来,大神帮帮我啊,急急急!

<i-table border :columns="columns" :data="data"></i-table>
import { Button, Icon, Form, FormItem, Input, Select, Option, Table, Page } from 'iview'
components: {
  IForm: Form,
  IFormItem: FormItem,
  IInput: Input,
  IButton: Button,
  ISelect: Select,
  IOption: Option,
  ITable: Table,
  IPage: Page
}
columns: [
  { title: 'NO', key: 'id' },
  { title: 'Name', key: 'name' },
  { title: 'Age', key: 'age' },
  { title: 'Created Date', key: 'time' },
  {
    title: 'Action',
    key: 'action',
    render: (h, params) => {
      return h('i-button')
    }
  }
],
data: [
  { id: 1, name: 'David Lee', age: 18, time: '2016-06-12' },
  { id: 1, name: 'David Lee', age: 18, time: '2016-06-12' },
  { id: 1, name: 'David Lee', age: 18, time: '2016-06-12' },
  { id: 1, name: 'David Lee', age: 18, time: '2016-06-12' },
  { id: 1, name: 'David Lee', age: 18, time: '2016-06-12' }
]

图片描述

阅读 10.7k
4 个回答

写错了。
应该是:

return h(IButton)
render: (h, params) => {return h('div', [
                            h('Button', {
                                props: {
                                    type: 'info',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        
                                    }
                                }
                            }, '查看')
                            ]);
}
新手上路,请多包涵

h(Button) // 不要引号,直接把引入的Button组件穿进去

新手上路,请多包涵

局部引入的,用Vue.compomemt解决这个问题,例如:
import Vue from 'vue';;
import Button from 'iview/src/components/button';
Vue.component('i-button', Button);
原因只是局部引入了,但渲染的还是没有

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