“Zdobądź reakcję URL” Kod odpowiedzi

Jak uzyskać bieżący adres URL za pomocą JavaScript lub React

const currentURL = window.location.href // returns the absolute URL of a page

const pathname = window.location.pathname //returns the current url minus the domain name
Terrible Teira

Zdobądź reakcję URL

window.location.href
Inquisitive Impala

Zdobądź bieżący router reagujący URL

import {withRouter} from 'react-router-dom';

const SomeComponent = withRouter(props => <MyComponent {...props}/>);

class MyComponent extends React.Component {
  SomeMethod () {
    const {pathname} = this.props.location;
  }
}
Jolly Jaguar

Odpowiedzi podobne do “Zdobądź reakcję URL”

Pytania podobne do “Zdobądź reakcję URL”

Więcej pokrewnych odpowiedzi na “Zdobądź reakcję URL” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu