关于Nuxt.js 出现HTMLElement is not define此类问题,解决方法。
方法一:(完美解决)
// nuxt.config.js文件
global.HTMLElement = typeof window === 'undefined' ? Object : window.HTMLElement
export default {
}
方法二:(不建议)
import Vue from 'vue'
export default () => {
if (process.browser) {
//console.log('浏览器端渲染');
Vue.use(require('element-ui'),require('element-ui/lib/locale/lang/en'))
} else {
//console.log("非浏览器端渲染");
}
}
方法三: (不建议)
plugins: [
// '@/plugins/element-ui',
{ src: '@/plugins/element-ui', ssr: false}
]
报错:
[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.