JS 判断空字符串
发布日期:2021-05-14 09:31:48 浏览次数:11 分类:博客文章

本文共 1358 字,大约阅读时间需要 4 分钟。

JS ������������������

���������������������������������������������������������������������������������������������������������

1���typeof ������ undefiend

typeof������������������������2������������������typeof(���������)���typeof ���������������������������������������������������������������������������������

typeof������������

  1. 'undefined' --������������������������
  2. 'boolean' --���������������������������
  3. 'string' --������������������������������
  4. 'number' --���������������������������
  5. 'object' --������������������������������������null(���������js������������������������null������object������������)
  6. 'function' --���������������������������
var content;if(typeof content === "undefined")  //true

������������������������������ undefined

2���������null

var content = null;if(typeof content === null)  //true

3���trim()������������

trim() ������������������������������������������������������������������������������������ tab������������������������������������

var content = "             ";           //������������if(typeof content.trim() === "")             //true

4���������������

������������������������������������������������������������

if(typeof content === "undefined" || content === null || content.trim() === "") {    this.$message({        showClose: true,        message: '������������',        type: 'error'    });}

���������������

上一篇:div 实现光标悬停变成手型
下一篇:信号与系统复习与总结

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年04月07日 23时23分54秒