Title: | 'Vuejs' Helpers and 'Htmlwidget' |
---|---|
Description: | Make it easy to use 'vue' in R with helper dependency functions and examples. |
Authors: | Evan You [aut, cph] (vue library in lib, https://vuejs.org/; see BACKERS for full list of Patreon backers), Kent Russell [aut, cre] (R interface) |
Maintainer: | Kent Russell <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.6.0 |
Built: | 2024-10-25 02:44:12 UTC |
Source: | https://github.com/vue-r/vueR |
Dependencies for Vue
html_dependency_vue(offline = TRUE, minified = TRUE)
html_dependency_vue(offline = TRUE, minified = TRUE)
offline |
|
minified |
|
Other dependencies:
html_dependency_vue3()
if(interactive()){ library(vueR) library(htmltools) attachDependencies( tagList( tags$div(id="app","{{message}}"), tags$script( " var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } }); " ) ), html_dependency_vue() ) }
if(interactive()){ library(vueR) library(htmltools) attachDependencies( tagList( tags$div(id="app","{{message}}"), tags$script( " var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } }); " ) ), html_dependency_vue() ) }
Dependencies for 'Vue3'
html_dependency_vue3(offline = TRUE, minified = TRUE)
html_dependency_vue3(offline = TRUE, minified = TRUE)
offline |
|
minified |
|
Other dependencies:
html_dependency_vue()
if(interactive()){ library(vueR) library(htmltools) browsable( tagList( tags$div(id="app","{{message}}"), tags$script( " var app = { data: function() { return { message: 'Hello Vue!' } } }; Vue.createApp(app).mount('#app'); " ), html_dependency_vue3() ) ) }
if(interactive()){ library(vueR) library(htmltools) browsable( tagList( tags$div(id="app","{{message}}"), tags$script( " var app = { data: function() { return { message: 'Hello Vue!' } } }; Vue.createApp(app).mount('#app'); " ), html_dependency_vue3() ) ) }
Use 'Vue.js' with the convenience and flexibility of 'htmlwidgets'.
vue
is a little different from other 'htmlwidgets' though
since it requires specification of the HTML tags/elements separately.
vue( app = list(), width = NULL, height = NULL, elementId = NULL, minified = TRUE )
vue( app = list(), width = NULL, height = NULL, elementId = NULL, minified = TRUE )
app |
|
width , height
|
any valid |
elementId |
|
minified |
|
vue htmlwidget
Other htmlwidget:
vue3()
if(interactive()) { library(vueR) library(htmltools) # recreate Hello Vue! example browsable( tagList( tags$div(id="app", "{{message}}"), vue3( list( el = "#app", data = list( message = "Hello Vue!" ) ) ) ) ) # app2 from Vue.js introduction browsable( tagList( tags$div(id="app-2", tags$span( "v-bind:title" = "message", "Hover your mouse over me for a few seconds to see my dynamically bound title!" ) ), vue( list( el = "#app-2", data = list( message = htmlwidgets::JS( "'You loaded this page on ' + new Date()" ) ) ) ) ) ) # app3 from Vue.js introduction # with a setInterval to toggle seen true and false browsable( tagList( tags$div(id="app-3", tags$p("v-if"="seen", "Now you see me") ), htmlwidgets::onRender( vue( list( el = '#app-3', data = list( seen = TRUE ) ) ), " function(el,x){ var that = this; setInterval(function(){that.instance.seen=!that.instance.seen},1000); } " ) ) ) }
if(interactive()) { library(vueR) library(htmltools) # recreate Hello Vue! example browsable( tagList( tags$div(id="app", "{{message}}"), vue3( list( el = "#app", data = list( message = "Hello Vue!" ) ) ) ) ) # app2 from Vue.js introduction browsable( tagList( tags$div(id="app-2", tags$span( "v-bind:title" = "message", "Hover your mouse over me for a few seconds to see my dynamically bound title!" ) ), vue( list( el = "#app-2", data = list( message = htmlwidgets::JS( "'You loaded this page on ' + new Date()" ) ) ) ) ) ) # app3 from Vue.js introduction # with a setInterval to toggle seen true and false browsable( tagList( tags$div(id="app-3", tags$p("v-if"="seen", "Now you see me") ), htmlwidgets::onRender( vue( list( el = '#app-3', data = list( seen = TRUE ) ) ), " function(el,x){ var that = this; setInterval(function(){that.instance.seen=!that.instance.seen},1000); } " ) ) ) }
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)
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) }
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) }
Use 'Vue.js 3' with the convenience and flexibility of 'htmlwidgets'.
vue3
is a little different from other 'htmlwidgets' though
since it requires specification of the HTML tags/elements separately.
vue3( app = list(), width = NULL, height = NULL, elementId = NULL, minified = TRUE )
vue3( app = list(), width = NULL, height = NULL, elementId = NULL, minified = TRUE )
app |
|
width , height
|
any valid |
elementId |
|
minified |
|
vue htmlwidget
Other htmlwidget:
vue()
if(interactive()) { library(vueR) library(htmltools) # recreate Hello Vue! example browsable( tagList( tags$div(id="app", "{{message}}"), vue3( list( el = "#app", # vue 3 is more burdensome but robust requiring data as function # if data is not a function then widget will auto-convert data = list(message = "Hello Vue3!") # data = htmlwidgets::JS(" # function() {return {message: 'Hello Vue3!'}} # ") ) ) ) ) # app2 from Vue.js introduction browsable( tagList( tags$div(id="app-2", tags$span( "v-bind:title" = "message", "Hover your mouse over me for a few seconds to see my dynamically bound title!" ) ), vue3( list( el = "#app-2", # vue 3 is more burdensome but robust requiring data as function # if data is not a function then widget will auto-convert data = htmlwidgets::JS(" function() { return {message: 'You loaded this page on ' + new Date()} } ") ) ) ) ) # app3 from Vue.js introduction # with a setInterval to toggle seen true and false browsable( tagList( tags$div(id="app-3", tags$p("v-if"="seen", "Now you see me") ), vue3( list( el = '#app-3', data = list(seen = TRUE), # data = htmlwidgets::JS("function() {return {seen: true}}"), mounted = htmlwidgets::JS(" function() { var that = this; setInterval(function(){that.seen=!that.seen},1000); } ") ) ) ) ) }
if(interactive()) { library(vueR) library(htmltools) # recreate Hello Vue! example browsable( tagList( tags$div(id="app", "{{message}}"), vue3( list( el = "#app", # vue 3 is more burdensome but robust requiring data as function # if data is not a function then widget will auto-convert data = list(message = "Hello Vue3!") # data = htmlwidgets::JS(" # function() {return {message: 'Hello Vue3!'}} # ") ) ) ) ) # app2 from Vue.js introduction browsable( tagList( tags$div(id="app-2", tags$span( "v-bind:title" = "message", "Hover your mouse over me for a few seconds to see my dynamically bound title!" ) ), vue3( list( el = "#app-2", # vue 3 is more burdensome but robust requiring data as function # if data is not a function then widget will auto-convert data = htmlwidgets::JS(" function() { return {message: 'You loaded this page on ' + new Date()} } ") ) ) ) ) # app3 from Vue.js introduction # with a setInterval to toggle seen true and false browsable( tagList( tags$div(id="app-3", tags$p("v-if"="seen", "Now you see me") ), vue3( list( el = '#app-3', data = list(seen = TRUE), # data = htmlwidgets::JS("function() {return {seen: true}}"), mounted = htmlwidgets::JS(" function() { var that = this; setInterval(function(){that.seen=!that.seen},1000); } ") ) ) ) ) }