I want to pass this prop as a string:
<list-view :avatar="pictures"></list-view>
But I think Vue thinks I am trying to call a method because I am getting these warnings:
[Vue warn]: Property or method "pictures" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
[Vue warn]: Invalid prop: type check failed for prop "avatar". Expected String, got Undefined.
How can I pass "pictures"
as a string?
Right now, Vue is trying to find a variable named
pictures
to pass as the property value to the child component.If you want to specify a string value in that inline expression, you can wrap the value in quotes to make it a string:
Alternately, as @Zunnii answered below, if the value being passed is really just a static string, you can simply omit the
v-bind
colon shorthand:This way, the
avatar
prop of the child component will be assigned the string value"pictures"
.If you really want to pass static string, you can just pass string directly without v-bind
then in JS file
JSFiddle => https://jsfiddle.net/dpLp4jk8/