共计 880 个字符,预计需要花费 3 分钟才能阅读完成。
写过 vue 的同学都晓得,单文件组件.vue 在开发中应用频率是十分高的。
如果不想再手写或者 CV 的话,无妨尝试一下我写的这个小工具,反对交互式生成.vue 文件,生成的过程只须要答复一些小问题即可。
目前仅反对 vue2 和局部属性,如果对这个我的项目感兴趣的话,欢送提 issue,欢送提 pr(适合的话我会第一工夫 merge),或者 fork 一份改成本人想要的成果吧
我的项目地址:
https://github.com/FrankKai/dot-vue-cli
dot-vue-cli
Vue2.x single file component .vue generator.
features
- Set
name
,props
,data
,computed
,watch
and chooselifecycles
,methods
by interactive command line. - Import vuex,
mapState
,mapMutations
,mapActions
by interactive command line.
install
npm install -g dot-vue-cli
usage
dot-vue
Type dot-vue
in terminal and follow the instructions.
process
1.generate template configs
{
filename: "foo",
name: "foo",
data: true,
"data details": "a,b,c",
computed: true,
"computed details": "a,b,c",
watch: true,
"watch details": "a,b,c",
methods: true,
"methods details": "a,b,c",
"vue lifecycle hooks": ["mounted", "destroyed"],
"vuex helpers": ["mapState", "mapMutations", "mapActions"],
};
2.generate target .vue file based on template literals
Enjoy it !
正文完