# vue-occupy

> A Vue directive for occupying content places before the data was loaded.

Latest version **0.0.9** (published 2017-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-occupy
pnpm add vue-occupy
yarn add vue-occupy
bun add vue-occupy
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2017-05-13 |
| First published | 2017-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 215 |
| Author | Jrain Lau |
| Maintainers | jrainlau |
| Keywords | vue, vue-occupy |

## Links

- npm: https://www.npmjs.com/package/vue-occupy
- Repository: https://github.com/jrainlau/vue-occupy
- Homepage: https://github.com/jrainlau/vue-occupyr#readme
- Issues: https://github.com/jrainlau/vue-occupy/issues
- npm.io page: https://npm.io/package/vue-occupy

## Recent versions

- 0.0.9 (latest) — 2017-05-13
- 0.0.8 — 2017-03-24
- 0.0.7 — 2017-03-24
- 0.0.6 — 2017-03-24
- 0.0.5 — 2017-03-24
- 0.0.4 — 2017-03-22
- 0.0.3 — 2017-02-27
- 0.0.2 — 2017-02-27
- 0.0.1 — 2017-02-27

## README

# Vue-Occupy
A Vue directive for occupying content places before the data has been loaded.

It's good for user experiment improving.

# Install
Using `yarn` or `npm` to install `vue-occupy`:

```
# yarn
yarn add vue-occupy

# npm
npm install vue-occupy
```

# Usage
In your `main.js` file:

```
import VueOccupy from 'vue-occupy'

Vue.use(VueOccupy)
```

Now `vue-occupy` is a global Vue directive, you can use `v-occupy` in every `.vue` file.

# Params

| param | type | description | necessary |
| --- | --- | --- | --- |
| data | {Object} | the data you bind to the node | Yes |
| config | {Object} | the color lump's css config | No |

For example:

```
<template>
  <div id="app" style="width:200px;height:50px;">
    <div v-occupy="{ data: content, config }"></div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      content: '',
      config: {
        width: '200px',
        height: '18px',
        background: '#ddd'
      }
    }
  },
  mounted () {
    fetch(url).then((result) => {
      this.content = result
    })
  }
}
</script>
```

Before the `fetch` method has requested the result data, the `div` with `v-occupy="{ data: content, config }"` would be occupying by a rectangle color lump. Once the data was loaded, the attribute `content` would be updated and be rendered into the html.

**Note**: the default configuration of `vue-occupy` looks like below:
```
{
  width: 100%; 
  height: 100%; 
  background: #eee
}
``` 
And the note with `v-occupy` will be like this:

```
<div v-occupy="{ data: content, config }">
  <div style="width: 100%; height: 100%; background: #eee;></div>
</div>
```

Which means your **must** set the exactly `width` and `height` attribute in the note with `v-occupy`, or overwrite the default configuration by binding `config` attribute.

# Lisence
MIT

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