嘿,伙计们,将Vue插件(使用表单vue.use()的UI元素)添加到代码库的首选方法是什么?
根据文档( https://docs.vuestorefront.io/guide/core-themes/plugins.html#theme-plugins ),我将以下代码添加到/src/themes/defaultx/plugins/index.js中
import Vue from 'vue'
import Toasted from 'vue-toasted'
Vue.use(Toasted)但它没有注册我的插件,并且在尝试使用它时抛出未定义的异常。
我尝试将Vue.use()放在Vue.use(processbar)所在的主题/index.js中,但将它放在那里(或其他任何导入Vue的地方)开始抛出“文档/窗口未找到”的错误。
我已经尝试了两个库: vue-notification和vue-toasted
附注:( defaultx只是default的一个简单副本)
发布于 2019-02-15 22:31:34
我猜文档中有一些地方遗漏了。
主题索引实际上是正确的位置,但错误是由SSR模式引起的。您只需要在客户端调用Vue.use (您可以使用Vue.prototype.$isServer或检查是否为window !== 'undefined')
https://stackoverflow.com/questions/54692348
复制相似问题