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)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM