Views: 1847
Last Modified: 28.04.2022

Directive naming mirrors component rules with single difference: target folder is directives instead of components .

All directives must be created as СoreJS extensions in new format.

JS main file content:

/**
* @package local
* @subpackage demo
* @copyright 2001-2022 Bitrix
*/

/* 
	Example of usage:
	...
*/

import {SomeClassForDirectiveLogic} from './logic'; // if needed

const directiveName = {
	created(element, bindings)
	{
		...
		SomeClassForDirectiveLogic::method(element);
		...
	}
};

Inside the file, you need to indicate an example of directive use, or a link to documentation in the format JsDoc.

When complex logic is required, you can move it outside of directive limits.

Variable name for export must start with lower case character.

Example of user directive in format Bitrix Core.js can be downloaded: here.





Courses developed by Bitrix24