Giter Site home page Giter Site logo

amt945 / vue-occupy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jrainlau/vue-occupy

0.0 0.0 0.0 386 KB

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

Home Page: https://jrainlau.github.io/vue-occupy/

License: MIT License

JavaScript 89.91% Vue 8.43% HTML 1.65%

vue-occupy's Introduction

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. What's more, attributes like marginTop or paddingRight are illegal, you should write in 'margin-top': '10px' or 'padding-right': '10px' instead.

Lisence

MIT

vue-occupy's People

Contributors

jrainlau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.