我想知道为什么我们用大写字母编写突变,动作和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
原文地址:https://www.jb51.cc/js/150989.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。