Component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods. Then selectors are modified so that only matching elements with this attribute are selected (e.g. For example: This isn’t recommended, as it results in: Component names should start with the highest-level (often most general) words and end with descriptive modifying words. v-for="user in users" v-if="shouldShowUsers"). Element selectors should be avoided with scoped. It lists component and shows live, editable usage examples based on Markdown files. However, mixed case filenames can sometimes create issues on case-insensitive file systems, which is why kebab-case is also perfectly acceptable. Over time, a number of programming patterns and style preferences have emerged in our efforts to effectively test Vue components. Documentation Style Guide. Definition (provides the component options), List Rendering (creates multiple variations of the same element), Conditionals (whether the element is rendered/shown), Render Modifiers (changes the way the element renders), Unique Attributes (attributes that require unique values), Two-Way Binding (combining binding and events), Other Attributes (all unspecified bound & unbound attributes), Content (overrides the content of the element). X The autocompletion in editors make the cost of writing longer names very low, while the clarity they provide is invaluable. It may include components like this one: As you might notice, it’s quite difficult to see which components are specific to the search. Element selectors should be avoided with scoped. In those cases, using kebab-case everywhere is also acceptable. However, we don't believe that any style guide is ideal for all teams or projects, so mindful deviations are encouraged based on past experience, the surrounding tech stack, and personal values. Our templates and JSX deserve the same consideration. vue-element-admin All global styles are set in the @/styles directory. `, ` For v3.x, click here. This is the official style guide for Vue-specific code. {{ todo.text }} In committed code, prop definitions should always be as detailed as possible, specifying at least type(s). Instead, we check it once and don’t even evaluate the v-for if shouldShowUsers is false. Within JavaScript, camelCase is more natural. Install Webpack if you don’t have it already, this is how we determine if your version of Webpack is... # In JavaScript, PascalCase is the convention for classes and prototype constructors - essentially, anything that can have distinct instances. Elements with multiple attributes should span multiple lines, with one attribute per line. The attributes of elements (including components) should be ordered consistently. Instead, we want each component instance to only manage its own data. $_yourPluginName_). You can use it to generate a static HTML page to share and publish or as a workbench for developing new components using hot reloaded dev server. # Style Guide. Ini adalah panduan resmi gaya menulis kode yang spesifik untuk Vue . For example, we might decide to display a message telling the user how much money they saved. Module based development. They’re split into categories, so you’ll know where to add new properties from plugins. Then you sort them alphabetically. Focus on one component at a time, see all its variants and work faster with hot reload. Your code will still run if you violate them, but violations should be rare and well-justified. _update) risks overwriting an instance property. This could be fixed by iterating over a computed property instead, like this: Alternatively, we can use a