A
A
aweui2019-01-24 14:11:11
Vue.js
aweui, 2019-01-24 14:11:11

How to get the length of a vue array?

Hello.
There is an array that lies in data

data () {
    return {
      arrayLength: array.length, // тут я делаю не правильно, я знаю
      array: [
        {
          title: '0'
        },
        {
          title: '1'
        },
        {
          title: '2'
        },

... and the length of which I want to put here: How to do it correctly? Thank you.
<p>{{ arrayLength }}</p> // должно получится 3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NaN, 2019-01-24
@aweui

in computed, you can calculate the length of the array and return it to the desired variable in data, set the initial value of this variable in the date arrayLength: null
or in created if when initializing the page, see how you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question