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