The problem of trinomial operation in vuex

if you use the trinomial operator in a project, eslint will report an error. How else can this trinomial operation be written?

data () {
    return {
      open: false,
      currentTab: false,
      isFolder: this.model.children && this.model.children.length ? true : false
    }
  },
Mar.21,2021

well, if you need a Boolean value, there is no need for trinomial operation to achieve the effect

data () {
    return {
      open: false,
      currentTab: false,
      isFolder: this.model.children && this.model.children.length // true or false
    }
}

if you must use it

data () {
    return {
      open: false,
      currentTab: false,
      isFolder: (this.model.children && this.model.children.length) ? true : false
    }
}

add that the operation priority of & & is lower than that of ?: , and the length attribute on the right is not the bool expression

.
clipboard.png
no, take


then you can turn this off in .eslintrc.js and you will not make a mistake


feel that it will be better to write this into the calculation attribute

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36a30-e57c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36a30-e57c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?