json获取服务器状态,无法从json服务器获取数据

我在Backbone.js中做了一个小项目,我正在运行一个json-server包来填充它的某些数据。我制作了一个带有数据的db.json文件,并运行了json-server --watch db.json,它启动并在localhost:3000上完美运行。在我的骨干网应用程序,我有这样的:无法从json服务器获取数据

// app/javascripts/collections/resumes.js

define(['backbone', 'models/resume'], function (Backbone, Resume) {

var ResumesCollection = Backbone.Collection.extend({

model: Resume,

url: 'http://localhost:3000/resumes'

});

return ResumesCollection;

});

// app/javascripts/views/resumes/resume.js

define(['backbone', 'jquery'], function (Backbone, $) {

var ResumeView = Backbone.View.extend({

tagName: 'article',

render: function() {

this.$el.html(this.model.get("firstName"));

return this;

}

});

return ResumeView;

});

// app/javascripts/views/resumes/index.js

define(['backbone', 'views/resumes/resume'], function (Backbone, ResumeView) {

var ResumesList = Backbone.View.extend({

tagName: 'section',

initialize: function() {

this.collection.fetch();

},

render: function() {

var resumesView = this.collection.map(function (cv) {

return new ResumeView({model: cv}).render().el;

});

this.$el.html(resumesView);

return this;

}

});

return ResumeList;

});

这是我app/router.js:

define(['backbone',

'collections/resumes',

'views/resumes/resume',

'views/resumes/index'],

function (Backbone, ResumesCollection, ResumeView, ResumeList) {

var AppRouter = Backbone.Router.extend({

routes: {

'resumes': 'showAll'

},

showAll: function() {

this.ResumeList.render();

}

});

return AppRouter;

});

和app/javascripts/main.js我有这样的:

require.config({

shim: {

underscore: {

exports: '_'

},

backbone: {

deps: [

'underscore',

'jquery'

],

exports: 'Backbone'

}

},

paths: {

jquery: '../node_modules/jquery/dist/jquery',

underscore: '../node_modules/underscore/underscore',

backbone: '../node_modules/backbone/backbone'

}

});

require(['backbone',

'jquery',

'router'

], function (Backbone, $, AppRouter) {

var Router = new AppRouter();

Backbone.history.start({

pushState: true,

root: '/'

});

});

而且我用咕嘟咕嘟运行开发服务器localhost:8080 via gulp-connect和gulp-livereload。但是,当我导航到localhost:8080/resumes时,它会返回我Cannot GET /resumes,但控制台中没有错误。我做错了什么?+

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值