nuxt.js 如何添加 Mint UI
nuxt.js 如何添加 Mint UI
同问!
不支持
接下来会支持吗? 如果不支持,我该如何让它能在nuxt.js使用呢
@yuchonghua 我支持,但没精力做
@QingWei-Li 方便给个我自己去实现支持的建议吗?
@QingWei-Li 期待能支持一下,或者给个实现方向,非常感谢您的回答!
Vue 有提供 vm.$isServer 的属性来判断当前环境是不是服务端,要做的事情就是
- 遇到操作 DOM 的地方就跳过 可以参考这条 PR https://github.com/ElemeFE/element/pull/1982
举个例子 https://github.com/ElemeFE/mint-ui/blob/69093cd074e7bb0f27e445a36f3af3654db138f7/packages/spinner/src/spinner/fading-circle.vue#L19 里面有 DOM 操作,那么应该改成
created() {
if (this.$isServer) return;
this.styleNode = document.createElement('style');
const css = `.circle-color-${this._uid} > div::before { background-color: ${this.spinnerColor}; }`;
this.styleNode.type = 'text/css';
this.styleNode.rel = 'stylesheet';
this.styleNode.title = 'fading circle style';
document.getElementsByTagName('head')[0].appendChild(this.styleNode);
this.styleNode.appendChild(document.createTextNode(css));
},
- 把
wind-dom换成 https://github.com/ElemeFE/element/pull/1982/files#diff-59f8408372ddda8f24a02c32d02f6547 因为 wind-dom 没有 window 的判断
其实是个体力活 🤷♀️
我这边可以帮助到您们的Mint UI 支持nuxt吗 如果我这边抽时间 我想支持一下,不知道您的如何看待
@yuchonghua 欢迎 👏
@QingWei-Li 后期遇到问题,期待您能百忙中抽一点点时间指导一下,谢谢
我现在已经fork,我是改那个分支呢
@QingWei-Li
@yuchonghua master
好的
我是改这个文件夹吗
if (this.$isServer) return;
是仅仅加在有dom的地方还是所有的 created() {呢
@QingWei-Li

@yuchonghua 不是说在 created 上加判断,我只是给了例子
建议你不要着急改,先了解下 SSR 的工作原理以及 Vue 的渲染机制,同时 Element 里我已经给了个示范你可以参考 https://github.com/ElemeFE/element/pull/1982
还有 issue 是拿来讨论问题,如果你要问问题去 Gitter 里,我也在那里面。毕竟每条 issue 评论其他关注者都会收到邮件。
Has been submitted to pull, please test, thank you
@QingWei-Li 你好,可以帮忙看一下吗
great! ssr现在支持了吗?求支持