Manipulate the <html> or <body> tag in React

前端 未结 2 477
逝去的感伤
逝去的感伤 2021-02-01 20:29

What is the best way to manipulate the or tags in React?

For example, dynamically setting \'lang\' attribute or chan

2条回答
  •  不知归路
    2021-02-01 20:47

    It's ok to change the lang property directly and you may do so changing the value of document.documentElement.lang

    For example:

    var newLang = 'fr';
    ...
    document.documentElement.lang = newLang; // will set the lang property to 'fr'
    

提交回复
热议问题