還在為寫.vue檔案煩惱嗎?快來用dot-vue-cli互動式生成吧!

趁你還年輕發表於2020-11-16
寫過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

  1. Set name, props, data, computed, watch and choose lifecycles, methods by interactive command line.
  2. 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 !

相關文章