뷰를 생성하면서 백본 모델의 일부 dafault 값을 출력하려고하는데 노드가 "Property '$'of of object #은 _.extend._ensureElement "의 함수가 아닙니다. 아래의 코드 에서처럼 모델에서 직접 기본값을 보여줄 수 있지만 뷰를 사용하는 것은 아닙니다. 예를 보여주기 위해 // myView = new firstView()를 주석 처리했습니다. 그래서 당신은 출력을 볼 수 있지만 곧 오류가 나는 의견을 제거합니다. 누락 된 점과 내가 잘못하고있는 점을 알려주십시오. 이미 $ (function() {}) 내에 코드를 래핑하려고했지만 행운은 없습니다.
express = require('express');
$ = require('jQuery');
_ = require('underscore');
Backbone = require('Backbone');
app = express();
app.use(express.static(__dirname + ''));
app.use(express.bodyParser());
app.listen(process.env.PORT || 3000);
Person = Backbone.Model.extend({
defaults: {
'name': 'Joe Blog',
'job': 'Web Developer'
}
});
firstPerson = new Person();
firstView = Backbone.View.extend({
initialize: function() {
this.render();
},
render: function() {
console.log(firstPerson.get('job'));
return this;
}
})
//myView = new firstView();
console.log(firstPerson.get('name'));
대단히 감사합니다. – user1336103