N
N
Nikitosiu2019-06-21 19:38:52
Vue.js
Nikitosiu, 2019-06-21 19:38:52

Vue.js pass array to component?

I have a component with an array of images, I want to pass an array of their addresses (src) to it in "props".
In this case, the addresses will always be different, I don't want to pass a variable with addresses, but I want to write them in place

<post
  avatar="./img/2.jpg"
  imgSrc="['./img/3.jpg', './img/2.jpg']"       //что тут написать?
  name="Terrance arnold"
  description="posted an updated"
  online="active 14 minutes ago"
  text="“Check if it can be corrected with overflow : hidden”"
></post>

//props of the required component
props: {
avatar: String,
name: String,
description: String,
online: {
  default: "Online",
  type: String
},
imgSrc: {
  type: Array,
  default: function() {
    return [];
  }
  
},
title: String,
text: String
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-06-21
@Nikitosiu

https://vuejs.org/v2/guide/components-props.html#P...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question