我正在用 vue 为 storyblok 构建一个插件。我决定将状态管理添加到插件而不是$emit()
一路备份组件树的回声室会更容易。main.js
我将 Vuex 安装到我的插件中,然后按照 Vuex 教程中的说明将其添加到文件中,但是我的main.js
文件没有像常规的 Vue 应用程序main.js
文件那样设置。
本教程告诉我们这样做
import Vue from 'vue'
import App from './App.vue'
import store from './store' //our Vuex store
Vue.config.productionTip = false
new Vue({
store, //passing in our store
render: h =>(App)
}).$mount('#app')
但是main.js
,由于是 storyblok 插件,我的文件看起来像这样
import Plugin from './Plugin.vue'
import store from './store' //I have no clue where to put this in the code below :(
if (process.env.NODE_ENV == 'development') {
window.Fieldtype = Plugin
let customComp = window.Storyblok.vue.extend(window.Fieldtype);
window.Storyblok.vue.component('custom-plugin', customComp);
window.StoryblokPluginRegistered = true;
} else {
let init = Plugin.methods.initWith()
window.storyblok.field_types[init.plugin] = Plugin
}
如您所见,设置完全不同,因为它旨在将 Vue 组件作为插件注入 storyblok,而不是设置新的 Vue 应用程序。有人知道我应该在这里做什么吗?