• 安装运行vue-element-admin的报错问题-解决办法



    在使用vue-element-admin时,使用命令安装:

    npm install -registry=https://registry.npm.taobao.org
    
    • 1

    会报错,不通过。需要修改两处。

    1.第一处

    在目录vue-element-admin-master\src\components\MarkdownEditor下index.vue文件,修改内容如下:

    <template>
      <div :id="id" />
    template>
    
    <script>
    // deps for editor
    import 'codemirror/lib/codemirror.css' 
    import '@toast-ui/editor/dist/toastui-editor.css' 
    import Editor from '@toast-ui/editor'
    import defaultOptions from './default-options'
    
    export default {
      name: 'MarkdownEditor',
      props: {
        value: {
          type: String,
          default: ''
        },
        id: {
          type: String,
          required: false,
          default() {
            return 'markdown-editor-' + +new Date() + ((Math.random() * 1000).toFixed(0) + '')
          }
        },
        options: {
          type: Object,
          default() {
            return defaultOptions
          }
        },
        mode: {
          type: String,
          default: 'markdown'
        },
        height: {
          type: String,
          required: false,
          default: '300px'
        },
        language: {
          type: String,
          required: false,
          default: 'en_US' // https://github.com/nhnent/tui.editor/tree/master/src/js/langs
        }
      },
      data() {
        return {
          editor: null
        }
      },
      computed: {
        editorOptions() {
          const options = Object.assign({}, defaultOptions, this.options)
          options.initialEditType = this.mode
          options.height = this.height
          options.language = this.language
          return options
        }
      },
      watch: {
        value(newValue, preValue) {
          if (newValue !== preValue && newValue !== this.editor.getMarkdown()) {
            this.editor.setMarkdown(newValue)
          }
        },
        language(val) {
          this.destroyEditor()
          this.initEditor()
        },
        height(newValue) {
          this.editor.height(newValue)
        },
        mode(newValue) {
          this.editor.changeMode(newValue)
        }
      },
      mounted() {
        this.initEditor()
      },
      destroyed() {
        this.destroyEditor()
      },
      methods: {
        initEditor() {
          this.editor = new Editor({
            el: document.getElementById(this.id),
            ...this.editorOptions
          })
          if (this.value) {
            this.editor.setMarkdown(this.value)
          }
          this.editor.on('change', () => {
            this.$emit('input', this.editor.getMarkdown())
          })
        },
        destroyEditor() {
          if (!this.editor) return
          this.editor.off('change')
          this.editor.remove()
        },
        setMarkdown(value) {
          this.editor.setMarkdown(value)
        },
        getMarkdown() {
          return this.editor.getMarkdown()
        },
        setHtml(value) {
          this.editor.setHtml(value)
        },
        getHtml() {
          return this.editor.getHtml()
        }
      }
    }
    script>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116

    2.第二处

    修改package.json文件:

    “tui-editor”: “1.3.3”, 修改为: “@toast-ui/editor”: “^3.1.3”,

    {
      "name": "vue-element-admin",
      "version": "4.4.0",
      "description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features",
      "author": "Pan ",
      "scripts": {
        "dev": "vue-cli-service serve",
        "lint": "eslint --ext .js,.vue src",
        "build:prod": "vue-cli-service build",
        "build:stage": "vue-cli-service build --mode staging",
        "preview": "node build/index.js --preview",
        "new": "plop",
        "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
        "test:unit": "jest --clearCache && vue-cli-service test:unit",
        "test:ci": "npm run lint && npm run test:unit"
      },
      "dependencies": {
        "axios": "0.18.1",
        "clipboard": "2.0.4",
        "codemirror": "5.45.0",
        "core-js": "3.6.5",
        "driver.js": "0.9.5",
        "dropzone": "5.5.1",
        "echarts": "4.2.1",
        "element-ui": "2.13.2",
        "file-saver": "2.0.1",
        "fuse.js": "3.4.4",
        "js-cookie": "2.2.0",
        "jsonlint": "1.6.3",
        "jszip": "3.2.1",
        "normalize.css": "7.0.0",
        "nprogress": "0.2.0",
        "path-to-regexp": "2.4.0",
        "screenfull": "4.2.0",
        "script-loader": "0.7.2",
        "sortablejs": "1.8.4",
        "@toast-ui/editor": "^3.1.3",
        "vue": "2.6.10",
        "vue-count-to": "1.0.13",
        "vue-router": "3.0.2",
        "vue-splitpane": "1.0.4",
        "vuedraggable": "2.20.0",
        "vuex": "3.1.0",
        "xlsx": "0.14.1"
      },
      "devDependencies": {
        "@vue/cli-plugin-babel": "4.4.4",
        "@vue/cli-plugin-eslint": "4.4.4",
        "@vue/cli-plugin-unit-jest": "4.4.4",
        "@vue/cli-service": "4.4.4",
        "@vue/test-utils": "1.0.0-beta.29",
        "autoprefixer": "9.5.1",
        "babel-eslint": "10.1.0",
        "babel-jest": "23.6.0",
        "babel-plugin-dynamic-import-node": "2.3.3",
        "chalk": "2.4.2",
        "chokidar": "2.1.5",
        "connect": "3.6.6",
        "eslint": "6.7.2",
        "eslint-plugin-vue": "6.2.2",
        "html-webpack-plugin": "3.2.0",
        "husky": "1.3.1",
        "lint-staged": "8.1.5",
        "mockjs": "1.0.1-beta3",
        "plop": "2.3.0",
        "runjs": "4.3.2",
        "sass": "1.26.2",
        "sass-loader": "8.0.2",
        "script-ext-html-webpack-plugin": "2.1.3",
        "serve-static": "1.13.2",
        "svg-sprite-loader": "4.1.3",
        "svgo": "1.2.0",
        "vue-template-compiler": "2.6.10"
      },
      "browserslist": [
        "> 1%",
        "last 2 versions"
      ],
      "bugs": {
        "url": "https://github.com/PanJiaChen/vue-element-admin/issues"
      },
      "engines": {
        "node": ">=8.9",
        "npm": ">= 3.0.0"
      },
      "keywords": [
        "vue",
        "admin",
        "dashboard",
        "element-ui",
        "boilerplate",
        "admin-template",
        "management-system"
      ],
      "license": "MIT",
      "lint-staged": {
        "src/**/*.{js,vue}": [
          "eslint --fix",
          "git add"
        ]
      },
      "husky": {
        "hooks": {
          "pre-commit": "lint-staged"
        }
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/PanJiaChen/vue-element-admin.git"
      }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112

    3.安装运行

    在nodejs 16.14.0 32位windows下测试通过。

    npm install -registry=https://registry.npm.taobao.org
    npm run dev
    
    • 1
    • 2
  • 相关阅读:
    TypeScript_基本类型
    OOP 向量加减(友元+拷贝构造)
    Day708.Tomcat和Jetty有哪些不同 -深入拆解 Tomcat & Jetty
    4D毫米波雷达和3D雷达、激光雷达全面对比
    【学习笔记41】DOM操作的练习
    Linux ———— 管理磁盘
    nginx rewrite参数 以及 $1、$2参数解析(附有生产配置实例)
    数据结构之线性表中的双向循环链表【详解】
    亚信科技与中国信通院达成全方位、跨领域战略合作
    玩一玩Spring容器
  • 原文地址:https://blog.csdn.net/m0_67316550/article/details/133772997