K
K
kr_ilya2019-06-10 17:00:40
JavaScript
kr_ilya, 2019-06-10 17:00:40

How to use standard javascript functions in vue?

Such a question arose when it was required to execute indexOf()
And he did not want to be executed with the error
Cannot read property 'indexOf' of undefined
at VueComponent

As in methods

videoShow(url){
      if(url.indexOf('.mp4') != -1){
        return true
      }else{
        return false
      }
    }

So directly in v-if The code gives this error. How to solve the problem?
v-if="url.indexOf('.mp4') !== -1"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Gribanov, 2019-06-10
@kr_ilya

Cannot read property 'indexOf' of undefined
It's not about vue, it's about the fact that you didn't pass the url to the method (or it's just undefined)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question