JSFiddle - React, Tailwind, and code Playground
by robedgenius
HTML
<script src="https://unpkg.com/vue@next"></script>
<div id="app">
<h2>test</h2>
<myc></myc>
</div>
CSS
.text-div{
font-size:12px;
color: black;
fill: black;
width: 200px;
height: 30px;
border: 1px solid #000;
}
svg{
fill:red;
}
JavaScript
const app = Vue.createApp({
data () {
return {
mytext: "hello from parent"
}
}
})
// Define a new global component called button-counter
app.component('myc', {
data() {
return this.$parent
},
template: `
<svg width="800" height="800" >
<foreignObject width="400" height="100">
<div>div:</div>
<div class="text-div" v-text="this.$parent.mytext"></div>
</foreignObject>
<foreignObject x="0" y="50" width="400" height="100">
<div>tspan, nothing below as v-text to an attribute:</div>
</foreignObject>
<text x="0" y="100">
<tspan v-text="this.$parent.mytext"></tspan>
</text>
<foreignObject x="0" y="150" width="400" height="100">
<div>tspan in mustache:</div>
</foreignObject>
<text x="0" y="200">
<tspan>{{this.$parent.mytext}}</tspan>
</text>
</svg>
`
})
app.mount('#app')