Skip to main content


fires before changing the active tab

beforeChange: (id: string, prev: string) => boolean | void;


  • id: string - the id of a newly active tab
  • prev: string - the id of a previously active tab


Return false to prevent an active tab from being changed; otherwise, true.

Example"beforeChange", function(id, prev){
console.log("The " + prev + " active tab will be changed");
return false;

Related sample: Tabbar. Events

For instance, you can define the logic for blocking the ability to switch between even tabs:"beforeChange", (id, prev) => {
const tabIndex =
tabbar.config.views.findIndex(tabObj => === tabbar.getCell(id);
if (tabIndex % 2 === 1) return false;

Change log:

added in v7.3