1.0.6 • Published 11 months ago

vue-auto-file v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

vue-auto-file

1、vue-auto-file 前端自动创建文件工具

2、自动创建src目录、api、router、views目录,减少vue新建文件的麻烦

我们新建xxx.vue页面文件的时候,一般都要写这些重复的代码:

vue文件

<template>
  <div></div>
</template>

<script>
export default {};
</script>

<style lang="scss" scoped></style>

路由文件

export default [
  {
    path: "/",
    meta: {
      title: "主页",
    },
    component: () => import("@/views/home"),
    children: [],
  },
];

api文件

export const getXXXXList = () => get("/XXXXXX");

每次都写这些代码,是不是很烦?

主角登场:vue-auto-file

安装

npm install vue-auto-file -g

使用

方式一:
vue-auto-file create 《project》

方式二:
vue-auto-file c 《project》

帮助

 vue-auto-file -h

效果

leMac-mini testAuto % vue-auto-file create test
created file Desktop/testAuto/src/views/test/index.vue
created file Desktop/testAuto/src/router/modules/test.js
created file Desktop/testAuto/src/api/test.js

leMac-mini testAuto % vue-auto-file create test
test已存在,请重新输入

这样在src目录下面自动生成视图文件、路由文件、api文件

备注: 1、需要安装sass 2、router目录下的routers文件为动态导入会直接引入modules下的所有的模块,路由配置根据版本自行处理

vue-router@4x示例:

import { createRouter, createWebHashHistory } from "vue-router";

import routes from "./routes";
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;

vue-router@3x示例:

import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes";

Vue.use(VueRouter);

const router = new VueRouter({
  mode: "history",
  routes,
});

export default router;
结束~~~
1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago