当前位置:首页 > 技术文章

vue-element-admin安装依赖报错问题解决办法

xcsyj3年前 (2023-12-25)技术文章2341

vue-element-admin搭建过程中可能会遇到各种各样的安装依赖问题,今天给大家分享一下如何解决这些问题。



1、本地安装node

首先本地安装后nodejs,我本地的版本如下:


PS E:\hgm\vue-admin\vue-element-admin> npm -v

6.14.16

PS E:\hgm\vue-admin\vue-element-admin> node -v

v14.19.1



配置淘宝镜像


#配置npm为淘宝镜像

npm config set registry https://registry.npm.taobao.org

#查看配置是否正确

npm config get registry




2、克隆vue-element-admin项目

本地新建文件夹,比如E:\\vue-admin 然后执行命令克隆项目


# 克隆项目

git clone https://github.com/PanJiaChen/vue-element-admin.git


克隆之后文档目录如下



3、处理tui-editor依赖报错

找到package.json 去掉 "tui-editor": "1.3.3"

路径:vue-element-admin的根目录

原因:tui-editor(富文本编辑器插件)更名造成的,现在已经改名为toast-ui/editor并且该文件名和方法名都进行可修改,所以需要手动处理。



修改内容如下:



然后执行单独安装tui-editor

因为vue-element-admin项目依赖tui-editor ,手动执行命令安装就行


npm install --save @toast-ui/vue-editor




4、安装其它依赖包

因为依赖包比较多,安装需要几分钟,大家耐心等几分钟。


npm install


注意:不要使用cnpm命令安装依赖包,会出现各种依赖问题。

5、替换使用tui-editor的内容

路径:E:\vue-admin\vue-element-admin\src\components\MarkdownEditor\index.vue

修改后的index.vue的完整内容,具体如下:



<template>

<div :id="id" />

</template>


<script>

// deps for editor

import 'codemirror/lib/codemirror.css' // codemirror

// 老版本注释掉

//import 'tui-editor/dist/tui-editor.css' // editor ui

//import 'tui-editor/dist/tui-editor-contents.css'

// editor content

//import Editor from '@tui-editor'

//替换为新的

import '@toast-ui/editor/dist/toastui-editor.css';

import Editor from '@toast-ui/vue-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>





修改内容:

导入的包


import '@toast-ui/editor/dist/toastui-editor.css';

import Editor from '@toast-ui/vue-editor'


index.vue 中方法替换

getValue和setValue分别换成getMarkdown和setMarkdown


6、启动项目

执行启动命令


npm run dev





说明:警告信息不影响正常启动

7、运行效果

登录界面



主界面



扫描二维码推送至手机访问。

版权声明:本文由旺牛吧发布,如需转载请注明出处。

本文链接:https://www.wangniu8.top/?id=21

分享给朋友:

相关文章

一次奇怪的无盘系统随机不能进入系统

一次奇怪的无盘系统随机不能进入系统

故障现象:不固定某台客户机,在开机的时候,随机多台卡在系统的启动界面,一直转圈,却无法进入系统,再次重启后,系统有可能可以正常进入。环境:系统:服务器win2008,云更新无盘系统,客户机win11主系统,次系统win7区域:一楼网吧,二、…

PVE开启IOMMU硬件直通功能

PVE开启IOMMU硬件直通功能

在使用PVE的PCI硬件直通网卡/显卡/硬盘等硬件的时候提示“No IOMMU detected, please activate it.See Documentation for further information."这是因…

Windows10关闭TCP窗口autotuning解除限制提升网速

Windows10关闭TCP窗口autotuning解除限制提升网速

升级了2.5G网络或万兆网络,测速却不正常以管理员身份打开cmd运行下面的代码可查看TCP参数设置netsh interface tcp show global我们可以看到自动调节接收窗口是打开的,如果我们只在乎网速而忽略其他性能,使用如下…

避坑指南:飞牛 FnOS重启后1panel就打不开web控制台,一次失败的“延时启动”尝试

0. 起因:一次失败的“延时启动”尝试 最初,为了确保飞牛 NAS 在开机后环境完全准备就绪,我尝试在 /etc/crontab 中添加定时任务来延时启动 1Panel: 然而测试发现该指令完全无效。为了排查原因,我进入 SSH 手动执行…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。