search

Home  >  Q&A  >  body text

javascript - Making a single-page application with react, how do you handle the titles of different pages?

Recently used react to create a single page page. Because there is only one main entrance.html that is rendered in the end. Render different components through routing. Is there any way to display the corresponding title through different components. Just use WeChat to open a page and the title part of the header.

巴扎黑巴扎黑2749 days ago479

reply all(3)I'll reply

  • 滿天的星座

    滿天的星座2017-05-19 10:25:41

    It’s actually very simple

    document.title = '标题'

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:25:41

    To make it simple, just use document.title="xxx" yourself.

    To be more standardized, use react-document-title to encapsulate it.

    But for WeChat, I don’t know if it can be used on ios.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:25:41

    Use document.title in componentWillMount

    reply
    0
  • Cancelreply