Vue naming convention

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

  1. views following folder represents the name of the module
  2. Of nouns (car, order, cart)
  3. Only one word (good: car order cart) (bad: carInfo carpage)
  4. Try is a noun (good: car) (bad: greet good)
  5. Beginning with a lowercase (good: car) (bad: Car)

vue naming files under views

  1. The following views vue document represents the name of the page
  2. Folder on the module below
  3. Only one folder will not appear in the case file, but directly on the views directory, such as Login Home
  4. Try noun
  5. Begin with a capital at the beginning of the word is the name of your module (CarDetail, CarEdit, CarList)
  6. Name at least two words (good: CarDetail) (bad: Car)
  7. Common end of a word there (Detail, Edit, List, Info, Report)
  8. At the end of Item represents the component (CarListItem, CarInfoItem)

vue method named

The method of placing the order vue

  1. components
  2. props
  3. data
  4. created
  5. mounted
  6. activited
  7. update
  8. beforeRouteUpdate
  9. metods
  10. filter
  11. computed
  12. watch

custom method name method

  1. 动宾短语(good:jumpPage、openCarInfoDialog)(bad:go、nextPage、show、open、login)
  2. The method begins with ajax get, post, ending data (good: getListData, postFormData) (bad: takeData, confirmData, getList, postForm)
  3. The method begins with an event on (onTypeChange, onUsernameInput)
  4. init, refresh the exception of the word
  5. Try using common words beginning (set, get, open, close, jump)
  6. CamelCase (good: getListData) (bad: get_list_data, getlistData)

Method data props Precautions

  1. Please initialize the data inside when using data in variables
  2. props specified type, ie type
  3. data base changes props parent component type with $ emit, directly change the complex type
  4. ajax request data spend isLoading, isError variable
  5. 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
  6. Form data wrapped in a layer form please

Life-cycle approach Precautions

  1. Mounted not, like the method of the write logic created, taking ajax data,
  2. Bus monitor event created inside



Guess you like

Origin www.cnblogs.com/amylis_chen/p/11331455.html