Saturday, September 7, 2019

The "data" option should be a function that returns a per-instance value in component definitions.

Hi Guys ,

In this blog I will share information related to error : The "data" option should be a function that returns a per-instance value in component definitions.

This error is related to data attribute .

Let us see the erroneous code .

` ,
data : {
stocks : [
{"name" : "HDFC" , "mCap": "1000Cr"} ,
{"name" : "ICICI" , "mCap": "100Cr"}
]
}
}

The error is due to Vue expects the data attribute to contain a function .
Let us fix this by wrapping our data in a function .

` ,
data: function () {
return {
stocks: [
{ "name": "HDFC", "mCap": "1000Cr" },
{ "name": "ICICI", "mCap": "100Cr" }
]
}
}


Hope this resolves the issue . Thanks !
Youtube link below :





No comments:

Post a Comment

ec2-user@ec2 Permission denied