文档:


  • doc: https://backbonejs.org/
  • doc-zh: https://www.backbonejs.com.cn/

Backbone依赖:


  • jquery
  • underscore

使用示例

<!-- 引入依赖 -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/underscore.js/1.13.0/underscore-umd-min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/backbone.js/1.4.0/backbone-min.js"></script>


<!-- html -->
<div id="container"></div>


<!-- script -->
<script type="text/javascript">
var AppView = Backbone.View.extend({
el: "#container",

// 创建后执行
initialize: function () {
this.render();
},

render: function () {
this.$el.html("<h1>Hello World!</h1>");
},
});

var appView = new AppView();
</script>

渲染结果

<div id="container"><h1>Hello World!</h1></div>


参考
w3cschool-backbonejs 教程