Home  >  Article  >  Web Front-end  >  How vue.js determines whether an object has a certain attribute

How vue.js determines whether an object has a certain attribute

王林
王林Original
2021-10-08 14:39:0710436browse

vue.js method to determine whether an object has a certain attribute: [if(row.hasOwnProperty('url')){//The 'url' attribute of the row object exists}else{//The row object does not exist 'url' attribute}].

How vue.js determines whether an object has a certain attribute

The operating environment of this article: windows10 system, vue 2.5.2, thinkpad t480 computer.

How do we determine whether an object has a certain attribute or field in vue?

The judgment method is as follows:

if(row.hasOwnProperty('url')){
    //row对象存在'url'属性
}else{
    //row对象不存在'url'属性
}

Recommended learning: php training

The above is the detailed content of How vue.js determines whether an object has a certain attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn