前端之家收集整理的这篇文章主要介绍了
[模板]新建一个Dojo的基础模板(自用),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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,_WidgetsInTemplateMixin],{
- templateString: template,constructor: function() {
- this.inherited(arguments);
- },postCreate: function() {
- this.inherited(arguments);
- }
- });
- });
模板的使用,在模板中调用模板也是一样的写法
- require([
- "js文件的路径/demo"
- ],function(demo) {
- var oDemo = new Demo();
- });