ソースを参照

fix: 第二次加载代办页标签标题不更新

lanjianrong 4 年 前
コミット
fca89f6aba
1 ファイル変更8 行追加1 行削除
  1. 8 1
      src/components/Navigation/index.tsx

+ 8 - 1
src/components/Navigation/index.tsx

@@ -28,8 +28,8 @@ class NavigationGuards extends Component<NavigationGuardsProps, any> {
    * 根据路由改变动态改变标签页title
    */
   changDocumentTitle = (path: string) => {
-
     const pathTitle = frameStore.routeNameMapping.get(path) as string
+
     if (!pathTitle) {
       document.title = consts.NAME
     }
@@ -47,10 +47,17 @@ class NavigationGuards extends Component<NavigationGuardsProps, any> {
     return !!authArray.find((item) => item === myPermis)
   }
 
+
+  componentDidUpdate() {
+    // 防止某些页面只走update,更新标签名
+    this.changDocumentTitle(this.props.location.pathname)
+
+  }
   componentDidMount() {
     this.changDocumentTitle(this.props.location.pathname)
   }
   shouldComponentUpdate(nextProps: any) {
+
     //与上次请求的路径相同时不重新渲染
     if (this.props.location.pathname === nextProps.location.pathname) return false
     return true