繁体   English   中英

ShinyMCE 在 renderUI 和 shinyDashboard 中不起作用

[英]ShinyMCE does not work in renderUI and shinyDashboard

这个 MWE 正在工作:

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(#uiOutput("body")
                                     tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  #output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

这是它的样子:

在此处输入图像描述

但是,如果我在renderUI tinyMCE

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(uiOutput("body")
                                     #tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

..它不能正常工作:

在此处输入图像描述

我需要使用renderUI ,因为我有几个元素要在主体中呈现。 有什么建议吗?

正如我在这里看到的。 我在 singleton 中添加了脚本源:

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(singleton(tags$head(tags$script(src = "//cdn.tiny.cloud/1/5a5deew2z9gml5pwn95iosioop446qny3vyfh994kujzkwu6/tinymce/5/tinymce.min.js", referrerpolicy="origin"))),
                                     uiOutput("body")
                                     #tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

它解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM