vue-shiny | R Documentation |
Output and render functions for using vue within Shiny applications and interactive Rmd documents.
Output and render functions for using 'vue 3' within Shiny applications and interactive Rmd documents.
vueOutput(outputId, width = "100%", height = "400px")
renderVue(expr, env = parent.frame(), quoted = FALSE)
vue3Output(outputId, width = "100%", height = "400px")
renderVue3(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width, height |
Must be a valid CSS unit (like |
expr |
An expression that generates a vue |
env |
The environment in which to evaluate |
quoted |
Is |
if(interactive()) {
library(shiny)
library(vueR)
ui <- tagList(
tags$div(id="app-3",
tags$p("v-if"="seen", "Now you see me")
),
vue3Output('vue1')
)
server <- function(input, output, session) {
output$vue1 <- renderVue3({
vue3(
list(
el = '#app-3',
data = list(seen = TRUE),
mounted = htmlwidgets::JS("
function() {
var that = this;
setInterval(function(){that.seen=!that.seen},1000);
}
"),
watch = list(
seen = htmlwidgets::JS("function() {Shiny.setInputValue('seen',this.seen)}")
)
)
)
})
# show that Shiny input value is being updated
observeEvent(input$seen, {print(input$seen)})
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.