22
rated 0 times
[
24]
[
2]
/ answers: 1 / hits: 15950
/ 7 Years ago, mon, january 16, 2017, 12:00:00
I have started playing with Vue
but faced an issue when trying to pass data to a component using props
. In the code below this.myData
(in the Hello.vue
) is undefined
for some reason
App.vue
<script>
import Hello from './components/Hello'
export default {
name: 'app',
data() {
return {
myData: 'this is my data'
}
},
components: {
Hello
} ...
</script>
Hello.vue
<script>
export default {
name: 'hello',
props: ['myData'],
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
mounted: function() {
console.log(this.myData)
}
} ...
</script>
More From » vue.js