用于闪亮应用程序的犀牛模块 - 我的应用程序无法运行

问题描述 投票:0回答:1

我正在尝试学习 rhino 模块来开发 R 闪亮的应用程序,但被这个简单的应用程序困住了:

应用程序/视图/page1.R

box::use(
    shiny[moduleServer, textOutput, renderText, NS, div],
    shiny.fluent[TextField.shinyInput, Stack]
)

#' @export
ui <- function(id){
    ns <- NS(id)
    Stack(TextField.shinyInput(ns("page1input"), value = "default value"),
          textOutput(ns('page1print'))
          )
}

#' @export
server <- function(id) {
    moduleServer(id, function(input, output, session){
        output$page1print <- renderText(sprintf("Input from above: %s", input$page1input))
    })
}

主.R

box::use(
  shiny[div, moduleServer, NS, renderUI, tags, uiOutput, renderText],
  shiny.fluent[fluentPage]
)

box::use(
  app/view/page1
)

#' @export
ui <- function(id) {
  ns <- NS(id)
  fluentPage(
    page1$ui('p1')
  )
}

#' @export
server <- function(id) {
  moduleServer(id, function(input, output, session) {
    page1$server('p1')
  })
}

我希望应用程序打印用户的输入,但事实并非如此。有人可以帮忙吗?非常感谢

shiny shinydashboard rhino shinymodules
1个回答
0
投票

您忘记在调用中添加命名空间

page1$ui

# main.R

#' @export
ui <- function(id) {
  ns <- NS(id)
  fluentPage(
    page1$ui(ns('p1')) # <- fixed here
  )
}

现在

main$server
能够从
page1$ui
读取输入。别担心,每个人都会犯几次这样的错误;)。

© www.soinside.com 2019 - 2024. All rights reserved.