2.1.2 • Published 5 years ago

vue-control-load v2.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

summarize

Auto loading plugin for vue. 👏 You don't need to write showLoading and hideLoading any more.

support axios and fetch. default intercept fetch.

Provide fetch intercept life cycle

Read the documentation on GitHub to see the renderings for each example

中文文档

usage mode

npm i vue-control-load

import ControlLoad from 'vue-control-load'

Vue.use(ControlLoad)  // default intercept fetch

or

Vue.use(ControlLoad,{
  axios
})

example

Local parameter binding

<template>
  <div class="about"
    v-loading="lo_search"
    v-partLoad="lo_search"
    element-loading-text="拼命加载中"
    @click="gets">
    66666
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data(){
    return{
      lo_search: false
    }
  }
  methods:{
    gets(){
      axios.get('/v2/movie/search?q=张艺谋')
    }
  }
}
</script>

loading

Multiparameter binding

<template>
  <div class="about"
    v-loading="lo_search"
    v-partLoad="['lo_search','lo_in_theaters']"
    element-loading-text="拼命加载中"
    @click="gets">
    66666
  </div>
  <el-button type="primary" 
    @click="posts"
    :loading="in_theaters_btn" 
    v-partLoad="in_theaters_btn">
    加载中
  </el-button>
</template>

<script>
export default {
  data(){
    return{
      lo_search: false, // Multi-parameter simply sets the value of the first parameter
      in_theaters_btn: false
    }
  },
  methods:{
    posts(){
      axios.post('/v2/movie/in_theaters')
    },
    gets(){
      axios.get('/v2/movie/search?q=张艺谋')
    }
  }
}
</script>

much-bind

cache Parameters using

app.vue

// cache It doesn't work on buttons
<script>
export default {
  methods:{
    posts(){
      axios.post('/v2/movie/in_theaters',{
        cache: true
      }),
      <!-- axios.get(url,{
        params: {
          cache: true
        }
      }) ,
      fetch(url,{
        cache: true
      }) -->
    }
  },
  mounted(){
    this.posts()
  }
}
</script>

cache

newly increased fetch intercept

import { fetchIntercept } from 'vue-control-load'

fetchIntercept.register({
  request: function (url, config) {
      // Modify the url or config here
      return [url, config];
  },

  requestError: function (error) {
      // Called when an error occured during another 'request' interceptor call
      return Promise.reject(error);
  },

  response: function (response) {
      // Modify the reponse object
      return response;
  },

  responseError: function (error) {
      // Handle an fetch error
      return Promise.reject(error);
  }
});

particulars

v-partLoad

BindingtypenameSample request
Html tegBoolean/Arraylo_search/v2/movie/search?q=张艺谋
button tegBoolean/Arrayin_theaters_btn/v2/movie/in_theaters
parametertypeRequest typeeffect
cacheBooleanget / postAfter true, the request does not change the value of the binding property, which defaults to false and is not valid for the button

versions

1.0.35 the front page

1.0.36 The status was not modified after the request failed

1.1.1 Add local binding to optimize listening mode

1.1.2 Optimize data update methods

1.1.7 Add button binding

1.1.9 Stable version

1.1.10 Remove all attributes

1.2.1 Parameter bindings have been added

1.2.4 Fixed bug reported by plugin under nuxt framework

1.2.8 babel es6

2.0.0 Add support for fetch

2.1.0 newly increased fetch intercept life cycle

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.0

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago