html文件,demo.html divdiv最外层需要用div标签括起来/div/div js文件,demo.js define(["dojo/_base/declare","dijit/_WidgetBase","dijit/_TemplatedMixin","dijit/_WidgetsInTemplateMixin","dojo/text!html文件的路径/demo.html"]
html文件,demo.html
<div> <div>最外层需要用div标签括起来</div> </div>
js文件,demo.js
define([ "dojo/_base/declare", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dijit/_WidgetsInTemplateMixin", "dojo/text!html文件的路径/demo.html" ], function(declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, template) { return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { templateString: template, constructor: function() { this.inherited(arguments); }, postCreate: function() { this.inherited(arguments); } }); });
模板的使用,在模板中调用模板也是一样的写法
require([ "js文件的路径/demo" ], function(demo) { var oDemo = new Demo(); });