Views: 2674
Last Modified: 28.04.2022

When your application have operated outside the current site (in widget format) and employed a special client - you need to update the format of registration and use.

Before:

import {Vue} from 'ui.vue';

class TaskManager
{
	...
	attachTemplate()
	{
		const context = this;
		const restClient = this.restClient;
		const pullClient = this.pullClient;
		        
		this.vm = new Vue({
		    el: this.rootNode,
			beforeCreate() 
			{
				this.$bitrixApplication = context;
				
				this.$bitrixRestClient = restClient;
				this.$bitrixPullClient = pullClient;
			},
			template: '<module-component/>'
		})
	}
	...
}

Now:

import {BitrixVue} from 'ui.vue3';

class TaskManager
{
	...
	
	attachTemplate()
	{
		const context = this;
		const restClient = this.#restClient;
		const pullClient = this.#pullClient;
		        
		this.#application = BitrixVue.createApp({
			beforeCreate() 
			{
				this.$bitrix.Application.set(context);
				
				this.$bitrix.RestClient.set(restClient);
				this.$bitrix.PullClient.set(pullClient);
			},
            components: {
				Component,
			},
			template: '<Component/>'
		});
		this.#application.mount(this.#rootNode);
	}
	...
}


For access to client inside components:

Before:

this.$root.$bitrixRestClient
this.$root.$bitrixPullClient

Now:

this.$Bitrix.RestClient.get()
this.$Bitrix.PullClient.get()

Note: Getters will operate even without installing special clients. In this case, uses the default clients specifically for current site.

Find more details in articles: Class for handling REST client and Class for handling Pull client.





Courses developed by Bitrix24