1 判断字符串为空

(1)第一种方法

var test="";
if(test==""||test==null||test==undefined){
    alert("为空");
}

(2)第二种方法

var test="";
if(!test){
    alert("为空");
}

2 判断字符串不为空

(1)第一种方法

var test="";
if(test!=""&&test!=null&&test!=undefined){
    alert("不为空");
}

(2)第二种方法

var test="";
if(!!test){
    alert("不为空");
}

其他方法

方法1: 编写isNil函数判断

function isNil(value) {
  return value === null || value === undefined
}
if (isNil(num)) {
  ...
}

方法2:用Lodash

import {isNil} from 'lodash'

if (isNil(num)) {
  ...
}

方法3:用新语法,双问号 ??

saveRow (record) {
    // 将错误提示的逻辑用箭头函数(一定要箭头函数,为了this能穿透到上一级作用域)包装
    const tip = ()=> {
        this.tableLoading = false
        this.$message.error('请填写完整信息。')
        return
    }
    const { num, id } = record
    num ?? tip() // ?? 操作符只会在 num 为null或undefined 执行 ?? 后面的语句
}

[slice、splice、split 三者的区别](https://www.notion.so/slice-splice-split-9912b632d58e4611901d3e41b8cf1fb8)