1

reactable(R 包 reactable)中的列可以使用样式列表、函数或 javascript 设置样式 - 如果我只想使用一种方式,则可以使用。这些如何组合(无需重写列表、函数或 javascript 代码?

例子:

library(reactable)

list_style <- list(background = "#eee")

js_style <- JS("
    function(rowInfo) {
      return {fontWeight: 'bold' }
    }
  ")

fn_style <- function(value) {
    color <- "#008000"
    list(color = color)
}

df <- data.frame(x = 1:10, y = 11:20)

reactable(
  df,
  columns = list(
    x = colDef(
      style = c(list_style, js_style, fn_style) # This generates the below error
    )
  )
)

错误:

Error in colDef(style = c(list_style, js_style, fn_style)) : 
  `style` must be a named list, character string, JS function, or R function
4

0 回答 0