Named views
The following is a folder views in page units of vue file or folder module consisting of, on the src directory under, and components, assets at the same level.
views folder under the name
- views following folder represents the name of the module
- Of nouns (car, order, cart)
- Only one word (good: car order cart) (bad: carInfo carpage)
- Try is a noun (good: car) (bad: greet good)
- Beginning with a lowercase (good: car) (bad: Car)
vue naming files under views
- The following views vue document represents the name of the page
- Folder on the module below
- Only one folder will not appear in the case file, but directly on the views directory, such as Login Home
- Try noun
- Begin with a capital at the beginning of the word is the name of your module (CarDetail, CarEdit, CarList)
- Name at least two words (good: CarDetail) (bad: Car)
- Common end of a word there (Detail, Edit, List, Info, Report)
- At the end of Item represents the component (CarListItem, CarInfoItem)
vue method named
The method of placing the order vue
- components
- props
- data
- created
- mounted
- activited
- update
- beforeRouteUpdate
- metods
- filter
- computed
- watch
custom method name method
- 动宾短语(good:jumpPage、openCarInfoDialog)(bad:go、nextPage、show、open、login)
- The method begins with ajax get, post, ending data (good: getListData, postFormData) (bad: takeData, confirmData, getList, postForm)
- The method begins with an event on (onTypeChange, onUsernameInput)
- init, refresh the exception of the word
- Try using common words beginning (set, get, open, close, jump)
- CamelCase (good: getListData) (bad: get_list_data, getlistData)
Method data props Precautions
- Please initialize the data inside when using data in variables
- props specified type, ie type
- data base changes props parent component type with $ emit, directly change the complex type
- ajax request data spend isLoading, isError variable
- Redundant data is not named, is now details page, your data is ajax request, it would declare an object called direct d, rather than each field declaration
- Form data wrapped in a layer form please
Life-cycle approach Precautions
- Mounted not, like the method of the write logic created, taking ajax data,
- Bus monitor event created inside