But I think Vue thinks I'm ...">

Vuejs components as string

I want to pass this support as a string:

<list-view :avatar="pictures"></list-view>

But I think Vue thinks I'm trying to call a method because I get these warnings:

[Vue warn]: Property or "property" images are not defined in the instance, but are specified during rendering. Be sure to declare the properties of the reactive data in the data parameter.

[Vue warn]: Invalid prompt: Failed to check the type for the avatar alert. The expected string received by Undefined.

How to pass "pictures"as a string?

Here is my jsfiddle

+4
source share
2 answers

Right now, Vue is trying to find a variable with a name picturesto pass as a property value to a child component.

, , :

<list-view :avatar="'pictures'"></list-view>

, @Zunnii , , v-bind:

<list-view avatar="pictures"></list-view>

, avatar "pictures".

+6

, v-bind

<div id="app">
   <greeting text="world"></greeting>
</div>

JS

Vue.component('greeting', {
    props: ['text'],
  template: '<h1>Hello {{ text  }}!</h1>'
});


var vm = new Vue({
  el: '#app'
});

JSFiddle = > https://jsfiddle.net/dpLp4jk8/

+3

Source: https://habr.com/ru/post/1681736/


All Articles