iview table renderHeader用法

                    {
                        title: '平均正确率',
                        key: 'correctRate',
                        renderHeader: (h, params) => {
                            return h('span', [
                                h('Tooltip', {
                                    props: {
                                        content: "学生所有答题的平均正确率",
                                        trigger: 'hover',
                                        size: 'small',
                                        placement: 'top-start'
                                    }
                                }, [
                                    h('span', {
                                        domProps: {
                                            innerHTML: "平均正确率"
                                        }
                                    })
                                ])
                            ])
                        },
                        render(h, params) {
                            let answerRate = 0
                            if(params.row.answer_total_num) {
                                answerRate = params.row.answer_c_total_num / params.row.answer_total_num
                            }
                            return h('div', {
                                style: {
                                    display: 'flex',
                                    flexDirection: 'column'
                                }
                            }, [
                                h('span',{
                                    domProps: {
                                        innerHTML: `${Math.floor(answerRate * 100)}%`
                                    }
                                }),
                                h('span',{
                                    domProps: {
                                        innerHTML: `共计${params.row.level_total_num}篇`
                                    }
                                })
                            ])
                        }
                    },

 

你可能感兴趣的:(iview)