Nuxt throwing error : Uncaught TypeError: Cannot call a class as a function
Nuxt throwing error : Uncaught TypeError: Cannot call a class as a function
我在我的 Vuejs/Nuxtjs
应用程序中使用 drawflow
npm library 但是当我启动该应用程序时,我的控制台出现以下错误:
classCallCheck.js:3 Uncaught TypeError: Cannot call a class as a function
at _classCallCheck (classCallCheck.js:3)
以下是我根据文档遵循的步骤:
- 使用
npm i drawflow --save
安装 drawflow
- 在
plugins
文件夹下创建一个drawflow.js
文件并添加代码:
import Vue from 'vue'
import Drwaflow from 'drawflow'
Vue.use(Drwaflow)
- 修改
nuxt-config.js
文件并添加plugin
并构建:
plugins: [
{ src: "~/plugins/drawflow", mode:"client" }
],
build: {
transpile: ["drawflow"]
},
- 我的
Vue Component
在 Mounted
函数中有以下内容:
async mounted () {
const vm = this
if (process.browser) {
const Drawflow = await require('drawflow')
// const styleDrawflow = await require('drawflow/dist/drawflow.min.css')
Vue.use(Drawflow)
const id = document.getElementById('drawflow')
console.log(id)
vm.editor = new Drawflow(id, Vue, vm)
vm.editor.start()
}
}
不明白这里出了什么问题。找不到 Nuxt
的任何相关 post。有人可以解释一下这段代码有什么问题吗?
即使这个问题可以通过更多的工作解决,最后,OP 希望让它在本地工作。
此用例的解决方案是 并从我的 PoV 开始工作。
因此,我不建议采用插件路径,以防止它在全球范围内的整个 SPA 上可用。
我在我的 Vuejs/Nuxtjs
应用程序中使用 drawflow
npm library 但是当我启动该应用程序时,我的控制台出现以下错误:
classCallCheck.js:3 Uncaught TypeError: Cannot call a class as a function
at _classCallCheck (classCallCheck.js:3)
以下是我根据文档遵循的步骤:
- 使用
npm i drawflow --save
安装 - 在
plugins
文件夹下创建一个drawflow.js
文件并添加代码:
drawflow
import Vue from 'vue'
import Drwaflow from 'drawflow'
Vue.use(Drwaflow)
- 修改
nuxt-config.js
文件并添加plugin
并构建:
plugins: [
{ src: "~/plugins/drawflow", mode:"client" }
],
build: {
transpile: ["drawflow"]
},
- 我的
Vue Component
在Mounted
函数中有以下内容:
async mounted () {
const vm = this
if (process.browser) {
const Drawflow = await require('drawflow')
// const styleDrawflow = await require('drawflow/dist/drawflow.min.css')
Vue.use(Drawflow)
const id = document.getElementById('drawflow')
console.log(id)
vm.editor = new Drawflow(id, Vue, vm)
vm.editor.start()
}
}
不明白这里出了什么问题。找不到 Nuxt
的任何相关 post。有人可以解释一下这段代码有什么问题吗?
即使这个问题可以通过更多的工作解决,最后,OP 希望让它在本地工作。
此用例的解决方案是
因此,我不建议采用插件路径,以防止它在全球范围内的整个 SPA 上可用。