-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvue3_widget_examples.R
71 lines (66 loc) · 1.71 KB
/
vue3_widget_examples.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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);
}
")
)
)
)
)
}