3 Not clear from example what is $this
source | link

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this$block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can also pass action value instead of */*/* in above url, like 'customer/account/login' as per your required action.

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can also pass action value instead of */*/* in above url, like 'customer/account/login' as per your required action.

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can also pass action value instead of */*/* in above url, like 'customer/account/login' as per your required action.

2 added 130 characters in body
source | link

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can also pass action value instead of */*/* in above url, like 'customer/account/login' as per your required action.

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);

You can also pass action value instead of */*/* in above url, like 'customer/account/login' as per your required action.

1
source | link

You can simply call this method in magento 2 using below way,

//define query array pass to url
    $query = ['str1' => 'value1', 'str2' => 'value2',];
    $link = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);