当前位置 : 主页 > 网页制作 > Dojo >

[模板]新建一个Dojo的基础模板(自用)

来源:互联网 收集:自由互联 发布时间:2021-06-15
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();
});
网友评论