Summary of front-end code specifications

Some specification summaries made by myself

You can find a better reference on github

For vue:
props: The name is best to correspond to:

// good
export default {
    
    
  props: {
    
    
    'greeting-text': String,
  },
};

// bad
export default {
    
    
  props: {
    
    
    greetingText: String,
  },
};

<!-- good -->
<welcome-message greeting-text="hi" />
<!-- bad -->
<welcome-message greetingText="hi" />
  1. Order of components
组件选项的顺序
组件选项应该有统一的顺序。

export default {
    
    
  name: '',

  mixins: [],

  components: {
    
    },

  props: {
    
    },

  data() {
    
    },

  computed: {
    
    },

  watch: {
    
    },

  created() {
    
    },

  mounted() {
    
    },

  destroyed() {
    
    },

  methods: {
    
    },
};
  1. Blank lines in component options When
    importing multiple component files, it is recommended to wrap lines in order and regularly

  2. Notes for some complex logic and 函数的名字do, on handle ,get ,set ...

5.vue folder,

assets--- 静态资源, components----公共组件, router---路由, store---vuex
views----vue文件,  utils --放一些常用公共函数, 以及 axios请求  .针对页面监理文件, 在里面设置compoents 为页面组件

Guess you like

Origin blog.csdn.net/ZHXT__/article/details/109211710