【发布时间】:2022-01-12 02:44:58
【问题描述】:
我在我的 Nuxt 应用程序中的单个页面上使用 Vue2Editor。每当我测试应用程序并从应用程序的另一个页面导航到该页面时,它都可以正常加载而没有任何问题。但是当我测试并尝试直接打开该页面时,该应用程序失败并出现以下错误。我试图动态导入 vue-editor 包,但到目前为止还没有奏效。有什么想法可以在尝试直接访问页面时使此导入在页面上正常工作吗?
nuxt.config.js
plugins: [{src: './plugins/vue2-editor', ssr: true}]
plugins/vue2-editor.js
import Vue from 'vue'
if (process.BROWSER_BUILD) {
const VueEditor = require('vue2-editor')
Vue.use(VueEditor)
}
my_page.vue
<template><div><vue-editor></vue-editor></div></template>
<script>
...
import { VueEditor } from 'vue2-editor';
components: {
VueEditor
}
...
</script>
【问题讨论】:
-
嗨,我的回答有帮助吗?