我想在我的 vue 和 webpack 项目中使用 Ace 编辑器,我想用一个Ace Document
实例附加每个文件,所以我遵循(默认导入)
import Ace from 'ace-builds'
当我想创建一个文档时。
let doc = new Ace.Ace.Document('')
但是 Chrome 开发工具总是告诉我
TypeError: Cannot read property Document' of undefined at FileTree.vue:177
而且let doc = new Ace.Document('')
也不工作
我有一个导入 Ace 的 js 文件,它运行良好,代码在这里。编辑器.js
我的代码(在 vue 方法中:{}):
addFile (e) {
let tree = this.$refs.maintree
if (this.currentNode === undefined) {
this.currentNode = tree.getNode(1)
}
this.openAddFilePrompt().then(({value}) => {
let doc = new Ace.Ace.Document('')
if (this.currentNode.data.detail.type === 'file') {
let parentNode = this.currentNode.parent
tree.append({detail: {type: 'file', src: '', document: doc}, id: this.maxId++, label: value}, parentNode)
return
}
this.maxId++
tree.append({detail: {type: 'file', src: '', document: doc}, id: this.maxId, label: value}, this.currentNode)
}).catch((err) => {
console.log(err)
})
},
这是我的d.ts
文件ace-builds
从图片中可以看出,Document 接口放在 Ace 命名空间中,我将总模块导入为 Ace,所以我想我应该用 新建 Document 对象new Ace.Ace.Document
,即defaultImport.Namespace.Interface
文档界面如下。我ace-builds
通过 npm 安装export interface Document extends EventEmitter
ace-builds
文件夹结构如下
我的问题:
为什么我的导入不起作用,而且我无法创建文档对象?
我试图给你一切可以帮助你解决我的问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句