Extend BaseWidget

JavaScript is not a classical language. It is a prototypical object oriented language. As such, to make most developers comfortable with developing widgets, Web AppBuilder for ArcGIS uses Dojo's functions to create and extend classes. Web AppBuilder defines the BaseWidget class from which you create the child class, Widget.

Open Widget.js in a text editor. The basic code for extending BaseWidget is:

define(['dojo/_base/declare', 'jimu/BaseWidget'],
function(declare, BaseWidget) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([BaseWidget], {
    // DemoWidget code goes here 

  });
});

The above code declares the DemoWidget class as a child class of BaseWidget. For more information, see dojo tutorials.