MaverickChan
2 months ago
396
2
Vue

Vue strange behavior of Data and Props

Posted 2 months ago by MaverickChan

this will work laravel blade file

<vue-component :anything="{{ $anything }}"></vue-component>

vue component

props: ['anything'],
data () {
	return {
		hello: this.anything.anything
	}
	
//console.log(this.hello) display ok

if in vue parent component

in parent component do this passing props to child

<vue-component :anything="anything"></vue-component> //anything is any type of data
props: ['anything'],
data () {
	return {
		hello: this.anything.anything
	}
	
//console.log(this.hello)same code but  display undefined 
//but computed property works
hello () {
	return this.anything.anything
} 

this is really annoying .... any explanation?

Please sign in or create an account to participate in this conversation.