Skip to content

Latest commit

 

History

History
 
 

12-async

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Asyncronous calls is vital in modern development. This clean example from jsfiddle shows how to send a async call with a one second delay.

Usage

console.clear()
console.log('Yes! We are using Vue version', Vue.version)

Vue.component('async-example', function (resolve, reject) {
  console.log('resolving component...')
  setTimeout(function () {
    resolve({
      template: '<div>I am async!</div>'
    })
  }, 1000)
})

// New VueJS instance
var app = new Vue({
	// CSS selector of the root DOM element
  el: '#app',
  // Some data
  data: () => ({
    show: false,
  }),
})
// Includes
<!-- Include the library in the page -->
<script src="https://unpkg.com/vue"></script>

<!-- App -->
<div id="app">
  <button @click="show ^= 1">Toggle</button>
  <async-example v-if="show"/>
</div>

Demo

https://peterlamar.github.io/vue-examples/async/

JS Fiddle

Locally

Open file index.html in a web browser

Reference

JS Fiddle