# rzs-spring

> vue应用 通用框架

Latest version **1.0.2** (published 2019-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install rzs-spring
pnpm add rzs-spring
yarn add rzs-spring
bun add rzs-spring
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-06-27 |
| First published | 2018-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 4 |
| Unpacked size | 71 KB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | no |
| Author | renzhsh |
| Maintainers | renzhsh |

## Links

- npm: https://www.npmjs.com/package/rzs-spring
- npm.io page: https://npm.io/package/rzs-spring

## Dependencies (4)

- [vue](https://npm.io/package/vue.md) ^2.5.8
- [vuex](https://npm.io/package/vuex.md) ^2.2.1
- [axios](https://npm.io/package/axios.md) ^0.15.3
- [vue-router](https://npm.io/package/vue-router.md) ^3.0.1

## Recent versions

- 1.0.2 (latest) — 2019-06-27
- 1.0.1 — 2019-06-27
- 1.0.0 — 2019-06-04
- 0.2.6 — 2019-03-26
- 0.2.5 — 2019-03-26
- 0.2.4 — 2019-03-26
- 0.2.3 — 2019-03-26
- 0.2.2 — 2019-03-26
- 0.2.1 — 2019-03-25
- 0.2.0 — 2019-03-25
- 0.1.1 — 2019-03-15
- 0.1.0 — 2018-12-07

## README

# Vue Spring 文档

在一个常规的前后端（Frontend for Backends）程序中，我们需要使用 VueRouter、Vuex，有时需要注册 API 或者注册插件等，
这些信息都是在全局性文件中进行配置的。这种全局性配置在大型项目中缺点就体现出来了，配置项多，维护困难。

Vue Spring 采用了分而治之的思想，将这些配置项划分成各个模块，并注册到 Vue 系统实例中，开发者只需维护自己关心的模块即可。

## 基本使用

```js
import SpringX from "rzs-spring";

// 按照spring规范封装好的模块
import System from "@/views/System";

import App from "./App";

const spring = new SpringX();

spring.use(System).setup({
    el: "#app",
    render: h => h(App)
});
```

## API

#### `SpringX()` 构造函数

#### `spring.use(option)`

通过`spring.use()`方法注入 vue 插件，配置路由列表和 store 项等

#### `spring.set(name, fn)`

通过`spring.set()`方法对模块的初始化进行配置

#### `spring.setup(option)`

通过`spring.setup()`方法对 Vue 的系统实例进行配置。`option`中可以包含 vue 的生命周期钩子函数，mixin、指令等。

### 模块配置示例

vue 插件开发参考[vue 插件](https://cn.vuejs.org/v2/guide/plugins.html)

```js
// system模块 index.js
{
    // vue插件
    install: (Vue, option) => {},
    // 路由配置
    route: {
        routeConfig: [
            {
                path: "/",
                component: resolve => {
                    require(["./Main"], resolve);
                }
            },
            {
                path: "/home",
                component: resolve => {
                    require(["./Home"], resolve);
                }
            }
        ];
    }

}
```

```js
// 用户管理模块 index.js
{
    // 路由配置
    route: {
        layout:'/', // 父组件路径
        routeConfig: [
            {
                path: "/user",
                component: resolve => {
                    require(["./User"], resolve);
                }
            }
        ];
    },
    vuex:{

    }
}
```

```js
// 系统入口 main.js
import System from "@/views/System";
import User from "@/views/User";

const spring = new SpringX();

spring.use([System, User]);
```

---
_Source: https://npm.io/package/rzs-spring · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
