Skip to content

Instantly share code, notes, and snippets.

@driedtoast
Last active June 28, 2018 20:22
Show Gist options
  • Save driedtoast/d750355dd2a23fb3ca1f9ac93f2114a0 to your computer and use it in GitHub Desktop.
Save driedtoast/d750355dd2a23fb3ca1f9ac93f2114a0 to your computer and use it in GitHub Desktop.
Quasar with vue resouce
// main.js
import Vue from 'vue'
import VueResource from 'vue-resource'
import Quasar from 'quasar'
import router from './router'
Vue.use(Quasar) // Install Quasar Framework
Vue.use(VueResource)
Quasar.start(() => {
/* eslint-disable no-new */
new Vue({
dataSharingHost: 'http://localhost:8080', // referenced via this.$root.$options.myHost
el: '#q-app',
router,
render: h => h(require('./App'))
})
})
@driedtoast
Copy link
Author

driedtoast commented Feb 20, 2017

for inside components :

 <button id="btn-get-random-word" v-on:click="getRandomWord">Get Random Word</button>
      <div id="my_view">
        <p>{{randomWord}}</p>
      </div>
export default {
  data () {
    return {
      randomWord: ''
    }
  },
  methods: {
getRandomWord: function () {
      this.randomWord = '...'
      this.$http.get(
        this.$root.$options.myHost + '/hello.json'
      ).then(function (response) {
        alert(response.data.constructor)
        this.randomWord = response.data
      }, function (error) {
        alert(error.data)
      })
    }    
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment