iview
iview copied to clipboard
nuxt.js服务端渲染框架,引入iview2后,使用任何组件都会出现如下的警告
iView 版本号
2.0.0-rc.5
操作系统/浏览器 版本号
window10/Chrome 56
Vue 版本号
2.2.4
能够复现问题的在线示例(重要)
这个服务渲染的在线demo不好整,大致步骤是:
vue init nuxt/starter myapp
cd myapp
yarn
npm run dev
启动后,创建插件:
import Vue from 'vue'
if (process.BROWSER_BUILD) {
Vue.use(require('iview'))
}
在nuxt.config.js引入
plugins: ['~plugins/vue-iview'],
css: ['iview/dist/styles/iview.css'],
此时一切正常。iview组件样式都能正常引入,然后在index.vue里加入如下代码:
<div style="background:#eee;padding: 20px">
<Card :bordered="false">
<p slot="title">无边框标题</p>
<p>无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充无边框内容填充。</p>
</Card>
</div>
使用四五个组件浏览器都会出现警告:
[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.
复现步骤
问题现象,以及你期望的结果是怎样的?
不要出现警告
你估计可能的原因是什么(选填)?
个人认为是iview代码问题,因为我那项目刚创建也没写多少代码,给个vue有人提的issue
这个问题我也遇到了,你是怎么解决的?
@Lurkerc 不解决了,后来我换成element-ui也有这个警告,,本来想忽略这个警告,发现打包后运行样式没起作用后,就直接放弃了,现在样式用bootstarp,打包丢到服务器运行啥问题都没有。
@Lurkerc 不考虑服务端渲染在用iview,笔记一般门户网站这种也不需要iview这些组件。坐后端再用。
@longzhaobi get,thx
iview suport ssr after 2.0.0-rc.19