Send commands to a Vue instance in a Shiny app
Update data in a Vue instance
1 2 3 4 | vueProxy(outputId, session = shiny::getDefaultReactiveDomain(),
deferUntilFlush = TRUE)
vueUpdateData(proxy, ...)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ui <- div(
tags$label("Enter username"),
tags$input(type = 'text', "v-model" = "username"),
tags$p("Vue -> Vue: Hello {{username}}"),
actionButton("set_name", "Shiny -> Vue"),
verbatimTextOutput("username")
) %>%
vue(
data = list(username = ""),
# Vue UI -> Shiny UI
watch = vue_watch("username"),
elementId = "app"
)
server <- function(input, output, session){
# Shiny server -> Vue UI
observeEvent(input$set_name, {
vueProxy("app") %>%
updateProp("username", "Ramnath")
})
output$username <- renderPrint({
paste("Vue -> Shiny:", input$username)
})
}
shiny::shinyApp(ui = ui, server = server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.