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

王林
Release: 2020-11-17 09:39:58
Original
4815 people have browsed it

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)=='{}'
Copy after login

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

Object.keys(object).length==0
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template