Vant: nuxt中引用Toast,刷新时报错

Created on 9 Oct 2018  ·  9Comments  ·  Source: youzan/vant

Describe the bug
在nuxt中,引用Toast,服务端渲染报错

vant插件代码 plugins/vant

import Vue from 'vue';

import { Checkbox, Button, Dialog, Popup, Toast } from 'vant';

Vue.use(Checkbox);
Vue.use(Button);
Vue.use(Dialog);
Vue.use(Popup);
Vue.use(Toast);

页面组件代码 page:

import { Toast } from 'vant';

...

Toast.loading({
      message: '加载中...'
});

nuxt配置代码 nuxt.config.js:

  build: {
    vendor: ['vant'],
    babel: {
      plugins: ['transform-vue-jsx', ['component', {
          libraryName: 'vant',
          styleLibraryName: 'vant-css',
          style: true
        }]]
    },

  ...

  plugins: [ '~/plugins/vant'  ]

Screenshots
1539074641 1

🐞 bug

All 9 comments

感谢反馈,下个版本会修复此问题

已在 1.3.5 版本修复

太高效了,为你打call

单例模式下完美运行。但是如果是多个toast运行时,代码会由于在服务端运行,Toast直接return空,导致一些方法如toast.clear()的未定义的问题。

发了个 1.3.7 版本,可以试下哈

nice

Toast多实例模式存在内存泄露的问题,实例可以复用,toast清除之后应该删除浏览器生成的DOM

@gongzhibin 可以新开个 issue

ok

Was this page helpful?
0 / 5 - 0 ratings

Related issues

353170753 picture 353170753  ·  3Comments

dhx1213 picture dhx1213  ·  4Comments

fengyun2 picture fengyun2  ·  3Comments

wang475293638 picture wang475293638  ·  3Comments

LiGuoBi picture LiGuoBi  ·  4Comments