The opening

  • Recently, I have been combining several projects’ code to spell out the short name of the functionProject Pinduoduo.
  • But several systems are missingeslintSomething like that. I don’t know what I was thinkingA lot of spellingPlus code checks.
  • And I did, and that led to some really weird and even cute code. It’s kind of a cautionary tale.

Some examples are

  • Ps sample code from the online community.

Loops do not declare useless variables

Don’t intemplateIt’s a long judgment, operation, because there’s something called a calculation property.

usegetCurrentInstanceTo obtainproxyDo you really need it? The most important thing is not to declare it but not to use it!

Do not declare unused variable functions!

  • Of course, sometimes, business changes forget to change! If so, it should be installedeslintAnd add code submission checks!

Declare all known variables and their child attributes in data

Do not name files arbitrarily

  • Check out the VUE Style Guide if you have any questions!

Please do not write strange logic, if you do write comments, for duplicate things, it is necessary to extract, this will make the code cleaner.

If you use itv-forPlease remember to addkeyOtherwise it would be like wearing no underwear!

A component needs a name, just like a person!

Don’t mixV - if, v - forAnd don’t write like the picture below!

  • Component in usev-forTraversal needs to be usedv-ifTo determine whether to load, you can use computed properties to process the data first and then apply it tov-forTraverse.
  • The following way, I guess maybe the data does not exist and do not show, butv-forNo data itself will not show ah!

Do not mix different operators

What is it trying to do?

  • obj[next.id]There is no operation, there is no assignment totrueAnd performcur.push(next)

Writing vUE is strongly recommendedStyle Guide click to view