1

这是我的第一篇文章。我很绝望。我正在尝试构建一个基于 vuejs、vuetify 和 vue-diff-patch-match 的应用程序。 vue-diff-match-patch。我不是程序员,而是 MD。我正在尝试为 ER 患者构建一个文本生成工具,这样我们就可以加快我们的文档流程并为我们的患者提供更多的实际时间。

不幸的是,当我编译我的项目时,我收到了这个错误:

Uncaught TypeError: Cannot set property 'diff_match_patch' of undefined

查看完整的错误消息:

Uncaught TypeError: Cannot set property 'diff_match_patch' of undefined
at eval (diffMatchPatch.js?8344:2189)
at Module../src/utils/diffMatchPatch.js (app.js:1519)
at __webpack_require__ (app.js:785)
at fn (app.js:151)
at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/vuetify-loader/lib/loader.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/SemanticDiff.vue?vue&type=script&lang=js&:7)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/vuetify-loader/lib/loader.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/SemanticDiff.vue?vue&type=script&lang=js& (app.js:958)
at __webpack_require__ (app.js:785)
at fn (app.js:151)
at eval (SemanticDiff.vue?f2f4:1)
at Module../src/components/SemanticDiff.vue?vue&type=script&lang=js& (app.js:1411)

我一直在做很多谷歌搜索,在 stackoverflow 上搜索和反复试验......但我无法再进一步了。

我不知道它是组件、底层 diffmatchpatch js lib、webpack 还是其他...

我会很感激任何提示!

提前谢谢!

实际代码:

    <template>
<sem-diff :left="text1" :right='text2'></sem-diff>
</template>

我尝试过两种方式:

  1. 直接导入 diffmatchpatch + 将代码复制到我自己的组件中:import { diff_match_patch, DIFF_EQUAL, DIFF_DELETE, DIFF_INSERT } from '../utils/diffMatchPatch'
  2. 组件导入,
import SemanticDiff from './SemanticDiff';
export default {
name: 'Covid19',
components: {
    TiptapVuetify,
    RichText,
    //'diff': Diff,
    //'line-diff': LineDiff,
    'sem-diff': SemanticDiff,
    //'processing-diff': ProcessingDiff,
},    
data() {
    return {
        //left: '',
        //right: '',
        //id: null,
        //html: '',
        text1: 'I am the very model of a modern Major-General, \n I\'ve information vegetable, animal, and mineral\n',
        text2: 'I am the very model of a cartoon individual,\n My animation\'s comical, unusual, and whimsical\n',

无论我是直接导入 diffMatchPatch 还是通过组件 -> 相同的错误。我在 diffMatchPatch Lib 的末尾找到了这个:

// Export these global variables so that they survive Google's JS compiler.
// In a browser, 'this' will be 'window'.
// Users of node.js should 'require' the uncompressed version since Google's
// JS compiler may break the following exports for non-browser environments.
this['diff_match_patch'] = diff_match_patch;
this['DIFF_DELETE'] = DIFF_DELETE;
this['DIFF_INSERT'] = DIFF_INSERT;
this['DIFF_EQUAL'] = DIFF_EQUAL;

export { diff_match_patch, DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL };

也许编译器会破坏代码?

4

0 回答 0