1:让DIV占满屏幕
$(window).height();$(window).width();可获取当前窗口大小,分别设为div的宽高即可。若父级元素无宽高,设置百分比无效。
2:Backbone不跳转的单页路由是使用
<a href="#xxx">实现的,一般没有#
3:Backbone需要用return的方式将view的构造函数暴露出来(类似jquery暴露$)
define(['jquery','backbone','underscore','main','bootstrap'],function($,Backbone,_){ var MDView = Backbone.View.extend({ el: 'body', template: _.template($("#markdown-temp").html()), events: { }, initialize: function(){ }, showView: function(){ this.$el.html(this.template()); }, render: function() { } }) return MDView; });
require(['jquery','backbone','underscore','markdown','main','bootstrap'],function($,Backbone,_,MDView){ var mainRouter = Backbone.Router.extend({ routes: { 'markdown': 'markdown', 'host': 'host', 'vm': 'vm', 'temp': 'temp' }, markdown: function(){ $("body").html("<div class='low-poly' style='background-image:url(pic/low-poly.jpg);100%;'><button class='btn btn-default inmark' style='margin-left:45%;margin-top:35%;opacity:0.3'>Start</button></div>"); $(".low-poly").css("height",$(window).height()+"px"); $(".inmark").click(function keke(argument) { mdviews.showView(); }) }, host: function(){ var li=$('.sidebar-items li').get(1); $(li).addClass('active'); show.target = "host"; host.showView(); }, vm: function(){ var li=$('.sidebar-items li').get(2); $(li).addClass('active'); show.target = "vm"; vm.showView(); }, temp: function(){ var li=$('.sidebar-items li').get(3); $(li).addClass('active'); show.target = "temp"; temp.showView(); } }); var MDView = Backbone.View.extend({ el: 'body', template: _.template($("#markdown-temp").html()), events: { }, initialize: function(){ }, showView: function(){ this.$el.html(this.template()); }, render: function() { } }) var mdviews = new MDView(); var router = new mainRouter(); Backbone.history.start(); })
4:详细学习正则和MarkDown语法
5:Markdown解析器:https://github.com/evilstreak/markdown-js
浏览器端解析有问题?