vue.js – Vuex:为什么我们用大写写突变,动作和getter?

我想知道为什么我们用大写字母编写突变,动作和getter的函数名?这个惯例来自哪里?
export default {
  SOME_MUTATION (state,payload) {

  },ANOTHER_MUTATION (state,}

解决方法

以全部大写形式写出常量是一个 long standing coding style.

来自Vuex documentation

It is a commonly seen pattern to use constants for mutation types in
varIoUs Flux implementations. This allows the code to take advantage
of tooling like linters,and putting all constants in a single file
allows your collaborators to get an at-a-glance view of what mutations
are possible in the entire application

因此,它实际上只是遵循了大部分命名常量大写的长期传统.这不是必需的.

Whether to use constants is largely a preference – it can be helpful in large projects with many developers,but it’s totally optional if you don’t like them

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...