Home >Web Front-end >Vue.js >What is the method to determine whether an object is empty in vue.js

What is the method to determine whether an object is empty in vue.js

王林
王林Original
2020-11-17 09:39:584829browse

The way vue.js determines whether an object is empty is to convert the object to json. If it is an empty collection {}, then the object is an empty object, such as [JSON.stringify(object)=='{ }'].

What is the method to determine whether an object is empty in vue.js

The method to determine whether the object is empty is as follows:

(Learning video recommendation: php video tutorial)

Method 1: Convert the object to JSON. If it is an empty collection {}, then it is an empty object.

JSON.stringify(object)=='{}'

Method 2: Determine the length of the object. If it is zero, it is an empty object.

Object.keys(object).length==0

Related recommendations: vue.js tutorial

The above is the detailed content of What is the method to determine whether an object is empty in vue.js. 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