0

我正在尝试添加类“活动”中包含的语言

我尝试这种方式,但它对我不起作用

    <div class="lang">
       <ul>
           @foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties)
              <li>
                  <a 
                      class="{{ Request::path() === LaravelLocalization::getLocalizedURL() ? 'active' : ''}}"
                      rel="alternate"
                      hreflang="{{ $localeCode }}"
                      href="{{ LaravelLocalization::getLocalizedURL($localeCode, null, [], true) }}">
                      {{ $properties['native'] }}
                  </a>                                    
              </li>
           @endforeach
       </ul>
     </div>
4

1 回答 1

2

你应该做:

{{ $localeCode == LaravelLocalization::getCurrentLocale() ? 'active' : ''}}
于 2020-08-26T23:13:29.987 回答