我定义了一个 vue 资源:
资源.js:
import Vue from 'vue'
import VueResource from 'vue-resource'
Vue.use(VueResource);
export const Team = Vue.resource('team{/id}{/action}');
因此,如果我在该资源上调用 get 方法:
api = require('.api/resources')
api.Team.get({
id: 3233,
action: 'details',
}).then(function(response) {
// ....
});
此 ajax 调用请求:
/team/3233/details
问题:
但是当我使用.update
or.save
而不是.get
时,请求 url 并不像预期的那样:
api = require('.api/resources')
api.Team.update({
id: 3233,
action: 'details',
}).then(function(response) {
// ....
});
我只向/team
请求正文中传输的所有参数发送请求。
如何在此类.save
或.update
ajax 调用中指定 url 参数?