Element: [Bug Report] 使用 nuxt.js el-table 组件不能通过 <nuxt-link> 不能设置页面 title

Created on 14 Apr 2017  ·  15Comments  ·  Source: ElemeFE/element

Element UI version

1.2.8

OS/Browsers version

win10 / chrome 57.0.2987.133

Vue version

2.2.6

Reproduction Link

https://jsfiddle.net/pj71jkyw/

Steps to reproduce

qq 20170414151314

What is Expected?

希望在通过 to outher page 能够正确显示 head:title

qq 20170414094756

What is actually happening?

image
当刷新页面的时候 是能够加载title的

Most helpful comment

All 15 comments

hi , I was tested on Glitch .

If use Table component on page , when it created will clean head ( nuxt.js use vue-meta )
If just Button component , every thing is OK

And , I just download component source and move Table in my project , vue-meta is working as normal .

Glitch test page
https://mica-sociology.glitch.me/

source code

thanks .

@ausir0726 thanks for you source code

Issue reproduction video gif
4 -14-2017 15-49-35

Just happend when you change link to the page have Table component .
titile will beccome http://xxx.xx.xx , actually is page with table

Is there a way to avoid this problem?

Can also confirm this with date picker and time picker

Detailed info with live sit and GIF: https://github.com/nuxt/nuxt.js/issues/664#issue-226443700
Sample repo: https://github.com/mikhailbot/elementui-test

@QingWei-Li @Leopoldthecoder Why is this problem no one to deal with it?

都去搞 element-react 了吗?都不管这个bug了。

i debug this and find that it maybe the bug of vue-meta or element Tooltip component.

vue-meta will check the meta and then refresh it before component mounted, but unlucky tooltip's $root is not __nuxt element. vue-meta can not get meta info from Tooltip so it use the default meta info which title is empty string, then document's title is set to empty by vue-meta.

there are there ways to solve this bug:

1、make the $root of Tooltip to be __nuxt which provide the right meta info for vue-meta, but i think it may be difficulty.

2、vue-meta change the title of default meta info to undefined so that it can updateTitle to document.title

3、vue-meta refresh meta info for component only its computed $metaInfo exists

i think the 3rd way is the right way to solve this bug.

@Leopoldthecoder 这个问题方便处理一下吗?

@Atinux I can still reproduce this with vue-meta 1.5.6, but the code fix should be inside. I will try to post a precise reproduction video / PR if I manage to deal with it

@Atinux @lordfuoco I too am noticing this issue for tooltip, date-picker, and loading.

Radio and popover does not seem to trigger this however.

Package Version:
nuxt: 2.4.3
element-ui: 2.4.10

I am currently using this quick fix, install it in the plugins of your nuxt.config.js and set ssr: false

export default function watchTitle() {
  let isRefreshing = false

  const observer = new MutationObserver(function(mutations) {
    const newValue = mutations[0].target.nodeValue
    if (newValue || isRefreshing) {
      isRefreshing = false
      return
    }
    isRefreshing = true
    $nuxt.$meta().refresh()
  })

  const target = document.querySelector('head > title')
  const config = { subtree: true, characterData: true, childList: true }
  observer.observe(target, config)
}

@jinusean thank you for the workaround! I will try to use it!

@jinusean thank you. Your fix worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smallpath picture smallpath  ·  3Comments

no5no6 picture no5no6  ·  3Comments

Kingwl picture Kingwl  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

fscardua picture fscardua  ·  3Comments