Published
Edited
Feb 23, 2022
3 forks
39 stars
Insert cell
Insert cell
Vue = import("https://unpkg.com/vue@3/dist/vue.esm-browser.js")
Insert cell
Insert cell
appEl = htl.html`<div id="app">
{{ message }}
</div>`
Insert cell
Insert cell
Vue.createApp({
data() {
return {
message: 'Hello Vue!'
}
}
}).mount("#app")
Insert cell
Insert cell
{
const el = htl.html`<div id="app">
{{ message }}
</div>`
yield el
Vue.createApp({
data() {
return {
message: 'Hello Vue!'
}
}
}).mount(el)
}
Insert cell
Insert cell
viewof value = html`<input type='text' value='Hello Observable!' />`
Insert cell
viewof app = {
const el = htl.html`<div id="appCustomValue">
{{ message }}
</div>`
yield el
const app = Vue.createApp({
data() {
return {
message: value
}
}
})
app.mount(el)

el.value = app
}
Insert cell
Insert cell
viewof app_holding_state = {
const el = htl.html`<div id="appCustomValue">
{{ message }}
</div>`
yield el
const app = Vue.createApp({
data() {
return {
message: `${viewof value.value}`
}
},
created() {
viewof value.addEventListener("input", e => {
const updatedInput = viewof value.value
this.message = updatedInput
})
}
})
app.mount(el)

el.value = app
}
Insert cell
Insert cell
viewof global = {
const app = Vue.createApp({})

const el = htl.html`<div id="app">
<apples></apples>
<bananas></bananas>
</div>`
yield el

app
.component("apples", {
template: `<div style="color:red">Apples!</div>`
})
.component("bananas", {
template: `<div style="color:yellow;background:black;">Bananas!</div>`
})

app.mount(el)
el.value = app
}
Insert cell
Insert cell
apples = ({
template: `<div style="color:red">Apples!</div>`
})
Insert cell
bananas = ({
template: `<div style="color:yellow;background:black;">Bananas!</div>`
})
Insert cell
{
const el = html`<div id="app">
<apples></apples>
<bananas></bananas>
</div>`
yield el
const app = Vue.createApp({
components: { apples, bananas }
})
app.mount(el)
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more