# vue-option-overwrite-strategies

> 将vue的合并策略改为覆写策略

Latest version **0.4.0** (published 2020-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-option-overwrite-strategies
pnpm add vue-option-overwrite-strategies
yarn add vue-option-overwrite-strategies
bun add vue-option-overwrite-strategies
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2020-07-03 |
| First published | 2020-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ajanuw |
| Maintainers | ajanuw |
| Keywords | Ajanuw, vue, vue-option-overwrite-strategies, vue覆写策略 |

## Links

- npm: https://www.npmjs.com/package/vue-option-overwrite-strategies
- Repository: https://github.com/januwA/vue-option-overwrite-strategies
- Issues: https://github.com/januwA/vue-option-overwrite-strategies/issues
- npm.io page: https://npm.io/package/vue-option-overwrite-strategies

## Recent versions

- 0.4.0 (latest) — 2020-07-03
- 0.3.1 — 2020-07-02
- 0.3.0 — 2020-07-02
- 0.2.0 — 2020-07-02
- 0.1.0 — 2020-07-02

## README

## 将vue的合并策略改为覆写策略，只处理生命周期钩子

> 如果覆写了钩子，那么必须使用`this.$$super.<hook name>()`手动触发(如果你需要的话)

> 如果没有覆写那么会自动执行继承的钩子，就和vue自带的合并策略一样

## Install
```
npm i vue-option-overwrite-strategies
```

## Example

1. main.js中使用
```
import App from "./app.vue";
import { OptionOverwriteStrategies } from "vue-option-overwrite-strategies";

Vue.use(OptionOverwriteStrategies, ["created"]);
```

2. 组件
```
import { mixin1, mixin2 } from "./mixins";
export default {
  name: "app",
  mixins: [mixin1, mixin2],
  data() {
    return {
      name: 'app'
    };
  },
  mounted() {
    console.log('widget mounted');
    this.$$super.mounted()
  }
};
```

3. mixins
```
const superMixin1 = {
  mounted() {
    console.log("superMixin1");
  },
};

export const mixin1 = {
  mixins: [superMixin1],
  mounted() {
    console.log("mixin1");
  },
};

export const mixin2 = {
  mounted() {
    console.log("mixin2");
  },
  created() {
    console.log("mixin1 create");
  },
};
```

4. 打印结果
```
mixin1 create
widget mounted
superMixin1
mixin1
mixin2
```

## dev
> $ npm start

## build
> $ npm run build


## See also:
- https://webpack.js.org/
- https://www.webpackjs.com/
- https://cn.vuejs.org/v2/api/index.html#optionMergeStrategies
- https://cn.vuejs.org/v2/guide/mixins.html

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