vue 调用 校验空值、null、undefined、[] v-if 标签内
校验空值、null、undefined、[]
/**
* @description: 校验空值、null、undefined、[]
* @param {*} val
* @return {*}
*/
export function verification(val) {
let valString = val + ""
let verificationType = ["", "null", "undefined"]
return verificationType.includes(valString)
}
vue 调用
属性判断:v-if="!verifications(val)"
标签判断:<diV>{{verifications(val)}}</div>
import { verification } from "@/utils/methods";
methods:
// 检验
verifications(key) {
return verification(key)
}
方法内判断调用:verification(val)