【Medium学习记录--002】12 Vue.js 的最佳实践

159 阅读1分钟

12 Vue.js Best Practices for Pro Developers 原文出处:medium.com/better-prog…

  1. v-for里面要用:key
  2. Events使用Kebab Case(短横线) using kebab case in both places. this.$emit('close-window') // then in the parent <popup-window @close-window='handleEvent()' />
  3. Declare Props With camelCase, and Use Kebab Case in Templates
  4. Data Should Always Return a Function data () { return { name: 'My Window', articles: [] } }
  5. v-for 里面不要用v-if
  6. Validate Your Props With Good Definitions
  7. Use PascalCase or Kebab Case for Components
  8. Base Components Should Be Prefixed Accordingly
  9. Components Declared and Used Once Should Have the Prefix “The”
  10. Stay Consistent With Your Directive Shorthand
  11. Don’t Call a Method on “created” and “watch”
  12. Template Expressions Should Only Have Basic JavaScript Expressions