Plugin options

We can configure the plugin with an options parameter:

  1. Edit the install method to add this parameter after Vue:
      export default {
install (Vue, options) {
console.log('Installed!', options)
},
}

We can now add a configuration object to the Vue.use() method in the main.js file.

  1. Let's add a baseUrl property to the configuration:
      Vue.use(VueFetch, {
baseUrl: 'http://localhost:3000/',
})

You should now see the options object in the browser console.

  1. Store baseUrl into a variable so we can use it later:
      let baseUrl

export default {
install (Vue, options) {
console.log('Installed!', options)

baseUrl = options.baseUrl
},
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.39.74