VueResource的一些设置
- 设置头部
// main.js Vue.http.options.root = 'https://ng-http-1528d.firebaseio.com/data.json'
- 设置headers
// main.js Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk';
- interceptors
// main.js Vue.http.interceptors.push(function(request, next){ request.headers['Authorization'] = 'YXBpOnBhc3N3b3Jk' next(response => response.json ) })
- custom actions & URI template
data(){ return { ... resource: {}, node: 'data' } } , methods: { submit(){ this.resource.saveAlt(this.user) },fetchData(){ this.resource.getData({node: this.node}) } }, created(){ const customActions = { saveAlt: { method: 'POST', url: 'alternative.json' }, getData: {method: 'GET'} } this.resource = this.$resource('{node}.json', {}, customActions) }