vue3实战项目安装各种爆时候报错问题和解决

news2025/3/1 14:00:53

文章目录

      • 1.安装:npm install -g sass
          • 报错问题1.npm install失败,报错如下
      • 引入使用echarts 相关
          • 问题1. vue3中npm install echarts --save报错
          • 但是这个地方有报提示,问题待解决...........


1.安装:npm install -g sass

注释: 多种安装方法
2.vue中局部引用,也可以设置全局css文件引入使用(使用场景全局的主题颜色更改等)

<style lang="scss" scoped>

overflow: hidden;溢出模块隐藏
visibility: hidden;隐藏全部

报错问题1.npm install失败,报错如下

https://www.baidu.com/s?ie=UTF-8&wd=npm%20ERR!%20Fix%20the%20upstream%20dependency%20conflict,%20or%20retry%20npm%20ERR!%20this%20command%20with%20–force,%20or%20–legacy-peer-deps%20npm%20ERR!%20to%20accept%20an%20incorrect%20(and%20potentially%20broken)%20dependency%20resolution.%20npm%20ERR!%20npm%20ERR!%20See%20D%3A%5Cnode%5Cnode_cache%5Ceresolve-report.txt%20for%20a%20full%20report.%20npm%20ERR!%20A%20complete%20log%20of%20this%20run%20can%20be%20found%20in%3A%20npm%20ERR!%20D%3A%5Cnode%5Cnode_cache%5C_logs%5C2023-03-03T04_20_57_593Z-debug-0.log

解决: npm install --legacy-peer-deps 即可成功安装 node_modules

引入使用echarts 相关

问题1. vue3中npm install echarts --save报错

npm WARN ERESOLVE overriding peer dependency npm WARN While resolving:
@element-plus/icons-vue@1.1.4 npm WARN Found: vue@3.0.0-beta.14 npm
WARN node_modules/vue npm WARN peer vue@“3.0.0-beta.14” from
@vue/compiler-sfc@3.0.0-beta.14 npm WARN
node_modules/@vue/compiler-sfc npm WARN peer
@vue/compiler-sfc@“^3.0.0-alpha.4” from vue-cli-plugin-vue-next@0.1.3
npm WARN node_modules/vue-cli-plugin-vue-next npm WARN 1 more
(the root project) npm WARN 5 more (vue-cli-plugin-vue-next,
vue-demi, …) npm WARN npm WARN Could not resolve dependency: npm
WARN peer vue@“^3.2.0” from @element-plus/icons-vue@1.1.4 npm WARN
node_modules/@element-plus/icons-vue npm WARN
@element-plus/icons-vue@“^1.1.4” from element-plus@2.2.2 npm WARN
node_modules/element-plus npm WARN npm WARN Conflicting peer
dependency: vue@3.2.47 npm WARN node_modules/vue npm WARN peer
vue@“^3.2.0” from @element-plus/icons-vue@1.1.4 npm WARN
node_modules/@element-plus/icons-vue npm WARN
@element-plus/icons-vue@“^1.1.4” from element-plus@2.2.2 npm WARN
node_modules/element-plus npm ERR! code ERESOLVE npm ERR! ERESOLVE
could not resolve npm ERR! npm ERR! While resolving:
@vue/eslint-config-typescript@5.0.2 npm ERR! Found:
eslint-plugin-vue@7.20.0 npm ERR! node_modules/eslint-plugin-vue npm
ERR! npm ERR! Could not resolve dependency: npm ERR! peer
eslint-plugin-vue@“^5.2.3 || ^6.0.0” from
@vue/eslint-config-typescript@5.0.2 npm ERR!
node_modules/@vue/eslint-config-typescript npm ERR! dev
@vue/eslint-config-typescript@“^5.0.2” from the root project npm ERR!
npm ERR! Conflicting peer dependency: eslint-plugin-vue@6.2.2 npm ERR!
node_modules/eslint-plugin-vue npm ERR! peer
eslint-plugin-vue@“^5.2.3 || ^6.0.0” from
@vue/eslint-config-typescript@5.0.2 npm ERR!
node_modules/@vue/eslint-config-typescript npm ERR! dev
@vue/eslint-config-typescript@“^5.0.2” from the root project npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this
command with --force, or --legacy-peer-deps npm ERR! to accept an
incorrect (and potentially broken) dependency resolution. npm ERR! npm
ERR! See D:\node\node_cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR!
D:\node\node_cache_logs\2023-03-03T04_29_35_204Z-debug-0.log

解决: npm install echarts --legacy-peer-deps
之后在App.vue中引入

import * as echarts from 'echarts'
import { provide } from 'vue'
 
export default {
  name: 'App',
  setup(){
    provide('echarts',echarts) 
  },
  components: {
  }
}

之后在新建echart.ts文件

import * as echarts from "echarts/core";

// 引入折线图、饼状图、柱状图
import { LineChart, PieChart, BarChart } from "echarts/charts";

// 引入提示框、标题、直角坐标系、数据集、内置数据转换器组件
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  LegendComponent,
} from "echarts/components";
// 标签自动布局,全局过渡动画等特性
import { LabelLayout, UniversalTransition } from "echarts/features";

echarts.use([LineChart, PieChart, BarChart, TitleComponent, TooltipComponent, GridComponent, DatasetComponent, TransformComponent, LegendComponent, LabelLayout, UniversalTransition]);

export default echarts;

引入使用

 <div id="main" style="width: 100%; height: 400px"></div>
import echarts from '../../utils/echart';
//注意这里引入了onMounted这个钩子,等会有用
import { onMounted, nextTick } from "vue";
export default {
  name: '',
  setup() {
    onMounted(() => {
      nextTick(() => {
        console.log(document.getElementById('hom_chart'))
        const myChart = echarts.init(document.getElementById('main'));
        myChart.setOption({
          title: {
            text: 'ECharts 入门示例'
          },
          tooltip: {},
          xAxis: {
            data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
          },
          yAxis: {},
          series: [
            {
              name: '销量',
              type: 'bar',
              data: [5, 20, 36, 10, 10, 20]
            }
          ]
        });

      })
    })
    return {
    }
  }

}

显示样式
在这里插入图片描述

但是这个地方有报提示,问题待解决…

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/404812.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C++:vector和list的迭代器区别和常见迭代器失效问题

迭代器常见问题的汇总vector迭代器和list迭代器的使用vector迭代器list迭代器vector迭代器失效问题list迭代器失效问题vector和list的区别vector迭代器和list迭代器的使用 学习C&#xff0c;使用迭代器和了解迭代器失效的原因是每个初学者都需要掌握的&#xff0c;接下来我们就…

C++代码格式化-clang-format

文章目录前言c|vscode|clang-formatc|vs|clang-formatc|.clang-format其他附录Visual Studio格式在vs和vscode中不同无法从繁体切换到简体我的vs code配置前言 一个项目中的代码&#xff0c;可能来自不同的地方。不管是多人合作&#xff0c;还是ctrl-c/ctrl-v&#xff0c;都有…

剑指offer JZ6 从尾到头打印链表

Java 剑指offer JZ6 从尾到头打印链表 文章目录Java 剑指offer JZ6 从尾到头打印链表一、题目描述二、递归写法三、栈方法使用Java的递归和栈解决从尾到头打印链表的问题 一、题目描述 输入一个链表的头节点&#xff0c;按链表从尾到头的顺序返回每个节点的值&#xff08;用数组…

spring cloud @RefreshScope 刷新机制

在学习 nacos 的配置修改发现用到了 RefreshScope 注解&#xff0c;将 spring boot 的日志调整如下logging:level:com:alibaba:cloud: debugorg:springframework:context: debugcloud: debug调用 nacos 的配置修改&#xff0c;看到如下信息2023-03-10 15:48:15.332 INFO [com.a…

三天吃透MySQL面试八股文

本文已经收录到Github仓库&#xff0c;该仓库包含计算机基础、Java基础、多线程、JVM、数据库、Redis、Spring、Mybatis、SpringMVC、SpringBoot、分布式、微服务、设计模式、架构、校招社招分享等核心知识点&#xff0c;欢迎star~ Github地址&#xff1a;https://github.com/…

MGRE综合实验

实验拓扑及相关要求&#xff1a; IP地址配置&#xff1a; ip规划如该拓扑上可视 缺省路由&#xff1a; [r1]ip route-static 0.0.0.0 0 15.0.0.2 [r2]ip route-static 0.0.0.0 0 25.0.0.2 [r3]ip route-static 0.0.0.0 0 35.0.0.2 [r4]ip route-static 0.0.0.0 0 45.0.0.2 公…

Java的二叉树、红黑树、B+树

数组和链表是常用的数据结构&#xff0c;数组虽然查找快&#xff08;有序数组可以通过二分法查找&#xff09;&#xff0c;但是插入和删除是比较慢的&#xff1b;而链表&#xff0c;插入和删除很快&#xff08;只需要改变一些引用值&#xff09;&#xff0c;但是查找就很慢&…

游戏引擎开发总结:序列化系统

序列化需要准备什么&#xff1f;首先&#xff0c;我们需要一个被序列化类实现序列化函数&#xff0c;以及序列化库。准备我的序列化库是Yaml-cpp&#xff0c;序列话函数就命名为Serialize&#xff0c;另外我们不需要关心组件类型是具体是什么&#xff0c;所以我这边使用多态&am…

Spring和MaBatis整合

Spring和MyBatis整合&#xff1a; 先瞅一眼各种文件路径&#xff1a; 将之前mybatis中的测试类中的SqlSessionFactory&#xff08;通过其openSession()来获得对象SqlSession&#xff09;&#xff0c;和Mybatis配置文件中的数据源&#xff08;url&#xff0c;username等&#…

【Java爬虫】HttpClient+Jsoup实现爬取校内新闻

警告网络爬虫作为一门技术&#xff0c;在使用过程中&#xff0c;应该遵守Robots协议。采集数据时应注意礼貌&#xff0c;不允许爬的网站尽量不要短时间大频率爬取&#xff0c;涉及hdd的网站更是不要去满足自己的好奇心&#xff0c;不然说不准哪天就和吴签一起吃大碗宽面了...介…

[洛谷-P2585][ZJOI2006]三色二叉树(树形DP+状态机DP)

[洛谷-P2585][ZJOI2006]三色二叉树&#xff08;树形DP状态机DP&#xff09;一、题目题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示数据规模与约定二、分析1、递归建树2、树形DP 状态机DP&#xff08;1&#xff09;状态表示&#xff08;2&#xff09;状态转移三、…

C++11异步编程

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录前言1、std::future和std::shared_future1.1 std:future1.2 std::shared_future2、std::async3、std::promise4、std::packaged_task前言 C11提供了异步操作相关的类…

Vue3电商项目实战-结算支付 2【03-结算-对话框组件封装、04-结算-收货地址-切换】

文章目录03-结算-对话框组件封装04-结算-收货地址-切换03-结算-对话框组件封装 目的&#xff1a;实现一个对话框组件可设置标题&#xff0c;动态插入内容&#xff0c;动态插入底部操作按钮&#xff0c;打开关闭功能。 大致步骤&#xff1a; 参照xtx-confirm定义一个基础布局实…

MFC常用控件使用(文本框、编辑框、下拉框、列表控件、树控件)

简介 本文章主要介绍下MFC常用控件的使用&#xff0c;包括静态文本框(Static Text)、编辑框(Edit Control)、下拉框(Combo Box)、列表控件(List Control)、树控件(Tree Control)的使用。 创建项目 我们选择 文件->新建->新建项目&#xff0c;选择MFC程序 选择基于对话…

二叉树的三种遍历

二叉树的遍历可以有&#xff1a;先序遍历、中序遍历、后序遍历先序遍历&#xff1a;根、左子树&#xff0c;右子树中序遍历&#xff1a;左子树、根、右子树后序遍历&#xff1a;左子树、右子树、根下面是我画图理解三种遍历&#xff1a;二叉树里都是分为左子树和右子树。分治思…

Linux文件基础I/O

文件IO文件的常识基础IO为什么要学习操作系统的文件操作C语言对于函数接口的使用接口函数介绍如何理解文件文件描述符重定向更新给模拟实现的shell增加重定向功能为什么linux下一切皆文件&#xff1f;缓冲区为什么要有缓冲区缓冲区对应的刷新策略缓冲区的位置在哪里文件的常识 …

VSCode:添加SSH远程连接

有的时候我们的代码保存于远程服务器&#xff0c;通过VSCode可以通过SSH进行连接&#xff0c;完成远程的编辑。在VSCode的扩展中安装Remote - SSH点击左侧工具栏的远程资源管理器&#xff0c;然后点加号输入ssh的机器及用户名选择一个用于保存ssh配置文件的路径&#xff0c;默认…

Tabs Studio 5.3.0 多功能标签 Crack

在 Visual Studio 2022 和 SQL Server Management Studio 中轻松处理任意数量和类型的文档 你爱写代码&#xff0c;不会好好扫描文档找到你需要切换到的文件名&#xff0c;然后扫描文件菜单下拉列表&#xff0c;然后求助于解决方案资源管理器或搜索。只有在您需要切换到另一个…

javascript入门基础

目录 前言 引入&#xff1a;html中嵌入javascript有三种方式 0. 变量&#xff08;var、let&#xff09; 1. 函数 1.1 普通函数 和 箭头函数 1.1.2 普通函数中的this 1.1.3 箭头函数没有自己的this 1.1.4 普通函数有arguments方法&#xff0c;箭头函数没有 1.1.5 箭头函…

MS python学习(9)

开始学习第二辑 more python for beginners talking about formating https://learn.microsoft.com/en-us/shows/more-python-for-beginners/formatting-and-linting–more-python-for-beginners-2-of-20 Formating 代码格式化&#xff1a;使用pylint工具来帮助遵循PEP8(pyt…