Skip to content

Instantly share code, notes, and snippets.

@patrickodacre
Last active November 18, 2016 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickodacre/4dc87667b5fb449b2b143a185d4c66d3 to your computer and use it in GitHub Desktop.
Save patrickodacre/4dc87667b5fb449b2b143a185d4c66d3 to your computer and use it in GitHub Desktop.
// export iife
export default (() => {
const options = {
name : 'UserList',
data,
methods: {
getUsers
}
}
return options
function data () {
return { users: [] }
}
function getUsers () {
return axios.get('someUrl')
.then((resp)=> {
this.users = resp.data
})
}
})()
// vs export options obj no iife
const options = {
name : 'UserList',
data,
methods: {
getUsers
}
}
function data () {
return { users: [] }
}
function getUsers () {
return axios.get('someUrl')
.then((resp)=> {
this.users = resp.data
})
}
export {options as default}
// vs format in docs:
export default {
name : 'UserList',
data () {
return { users: [] }
},
methods: {
getUsers () {
return axios.get('someUrl')
.then((resp)=> {
this.users = resp.data
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment