# vue-vnode-hook

> hook vnode for Vue

Latest version **2.0.0** (published 2023-08-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install vue-vnode-hook
pnpm add vue-vnode-hook
yarn add vue-vnode-hook
bun add vue-vnode-hook
```

## 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 | 2.0.0 |
| Published | 2023-08-30 |
| First published | 2023-08-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Moxun |
| Maintainers | mxstrive |
| Keywords | hook, vnode, Vue |

## Links

- npm: https://www.npmjs.com/package/vue-vnode-hook
- Repository: https://github.com/moxun1639/vue-vnode-hook
- Homepage: https://github.com/moxun1639/vue-vnode-hook#readme
- Issues: https://github.com/moxun1639/vue-vnode-hook/issues
- npm.io page: https://npm.io/package/vue-vnode-hook

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-08-30
- 1.0.1 — 2023-08-24
- 1.0.0 — 2023-08-24

## README

<h1 align="center">vue-vnode-hook</h1>

## Installation

```js
npm i vue-vnode-hook -S
```

## Examples

### install 

```js
import Vue from 'vue'
import VNodeHook from 'vue-vnode-hook'

Vue.use(VNodeHook)
```

### register hooks

- global hook (root component)
```js
const app = new Vue({
  render: h => h(App),
})

app.$vnhook.register({
  tag: 'el-column',
  beforeCreate(ctx, data, children) {
    // do something

    // 你可以在vm实例化之前设置data.attrs，
    // 这相当于在HTML标签中添加属性。

    // 你可以在children中追加vnode，
    // 这相当于在HTML标签内添加子元素。
  },
  created(ctx, vnode) {
    // do something

    // 此时vnode已创建，你访问修改vnode。
  },
})

app.$mount('#app')
```

- local hook (sub component)
```js
this.$vnhook.register({
  tag: 'el-column',
  beforeCreate(ctx, tag, data, children) {
    // do something

    // you can set data.attrs before the vm was instantiated,
    // this is equivalent to adding the attribute to the HTML tag.

    // You can append vnode in children,
    // this is equivalent to adding child elements inside HTML tags.
  },
  created(ctx, tag, vnode) {
    // do something

    // At this time, the vnode has been created, and you can access and modify the vnode.
  },
})
```

## Licence

This repository is licensed under the [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/) license.

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