Vue3安装dataV报错问题解决方案

 更新时间:2023年06月30日 08:32:19   作者:呆呆的机器人儿~  
这篇文章主要给大家介绍了关于Vue3安装dataV报错问题解决方案的相关资料,dataV用于大屏展示,个人觉得比echarts简单很多,需要的朋友可以参考下

安装

npm install @dataview/datav-vue3

引入

1. 完整引入

import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import dataV from '@dataview/datav-vue3';

const app = createApp(App);
app.use(dataV);
app.use(store);
app.use(router);
app.mount('#app');

报错

Compiled with problems:X

ERROR in ./src/main.ts 12:0-41

Module not found: Error: Can't resolve '@dataview/datav-vue3' in 'E:\Work\VSCodeTest\training\test\vue-test\src'


ERROR in ./src/main.ts 12:0-41

Module not found: Error: Can't resolve '@dataview/datav-vue3' in 'E:\Work\VSCodeTest\training\test\vue-test\src'


ERROR in src/main.ts:15:9

TS2769: No overload matches this call.
  Overload 1 of 2, '(plugin: Plugin_2<[{ classNamePrefix: string; }]>, options_0: { classNamePrefix: string; }): App<Element>', gave the following error.
    Argument of type 'typeof import("E:/Work/VSCodeTest/training/test/vue-test/node_modules/@dataview/datav-vue3/es/index")' is not assignable to parameter of type 'Plugin_2<[{ classNamePrefix: string; }]>'.
      Property 'install' is missing in type 'typeof import("E:/Work/VSCodeTest/training/test/vue-test/node_modules/@dataview/datav-vue3/es/index")' but required in type '{ install: (app: App<any>, options_0: { classNamePrefix: string; }) => any; }'.
  Overload 2 of 2, '(plugin: Plugin_2<{ classNamePrefix: string; }>, options: { classNamePrefix: string; }): App<Element>', gave the following error.
    Argument of type 'typeof import("E:/Work/VSCodeTest/training/test/vue-test/node_modules/@dataview/datav-vue3/es/index")' is not assignable to parameter of type 'Plugin_2<{ classNamePrefix: string; }>'.
      Property 'install' is missing in type 'typeof import("E:/Work/VSCodeTest/training/test/vue-test/node_modules/@dataview/datav-vue3/es/index")' but required in type '{ install: (app: App<any>, options: { classNamePrefix: string; }) => any; }'.
    13 |
    14 | const app = createApp(App);
  > 15 | app.use(DataV, { classNamePrefix: 'dv-' });
       |         ^^^^^
    16 | app.use(store);
    17 | app.use(router);
    18 | app.mount('#app')

2. 按需引入

<template>
  <BorderBox1>BorderBox1</BorderBox1>
</template>

<script lang='ts'>
import { BorderBox1 } from '@dataview/datav-vue3';
export default {
  components: {BorderBox1},
};
</script>

<style lang='scss'></style>

报错

Compiled with problems:X

ERROR in ./src/views/LargeDataScreen.vue?vue&type=script&lang=ts (./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/LargeDataScreen.vue?vue&type=script&lang=ts) 1:0-50

Module not found: Error: Can't resolve '@dataview/datav-vue3' in 'E:\Work\VSCodeTest\training\test\vue-test\src\views'

解决方案

1.忽略声明警告

文件:/src/shims-vue.d.ts

declare module '@dataview/datav-vue3';

2.dataV配置文件修改

文件:@dataview\datav-vue3/package.json

  // "module": "./es/index.js",
  "module": "./es/index.mjs",  // 修改后

3.如果使用完整引入,需要为datav配置文件添加相应方法

文件:@dataview\datav-vue3/es/index.mjs

// 全局注册方法
// 存在问题,未对setClassPrefix方法处理
// D、E、G...符号代表BorderBox1、BorderBox10、BorderBox11...组件名称
export default {
  install: (app, options) => {
    const components = [
	  D,
	  E,
	  G,
	  I,
	  K,
	  g,
	  C,
	  P,
	  h,
	  k,
	  u,
	  w,
	  z,
	  N,
	  Q,
	  S,
	  U,
	  W,
	  Y,
	  _,
	  oo,
	  eo,
	];
	components.map((component) => {
		app.component(component.name, component);
	});
  }
}

总结

到此这篇关于Vue3安装dataV报错问题解决方案的文章就介绍到这了,更多相关Vue3安装dataV报错内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Vue项目打包到服务器后请求接口报错404的解决

    Vue项目打包到服务器后请求接口报错404的解决

    这篇文章主要介绍了Vue项目打包到服务器后请求接口报错404的解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2023-05-05
  • 详解vue中axios请求的封装

    详解vue中axios请求的封装

    这篇文章主要介绍了vue中axios请求的封装,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-04-04
  • vue+springboot图片上传和显示的示例代码

    vue+springboot图片上传和显示的示例代码

    这篇文章主要介绍了vue+springboot图片上传和显示的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-02-02
  • vue项目中loadsh库常用方法说明

    vue项目中loadsh库常用方法说明

    这篇文章主要介绍了vue项目中loadsh库常用方法说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-11-11
  • Vue实现组件间通信的几种方式(多种场景)

    Vue实现组件间通信的几种方式(多种场景)

    本文主要介绍了Vue实现组件间通信的几种方式,不同的场景使用不同的方式,基本满足所有开发场景中的通信需求,感兴趣的可以了解一下
    2021-10-10
  • 详解VUE中v-bind的基本用法

    详解VUE中v-bind的基本用法

    本篇文章主要介绍了详解VUE中v-bind的基本用法 ,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-07-07
  • 默认浏览器设置及vue自动打开页面的方法

    默认浏览器设置及vue自动打开页面的方法

    今天小编就为大家分享一篇默认浏览器设置及vue自动打开页面的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-09-09
  • vue微信分享 vue实现当前页面分享其他页面

    vue微信分享 vue实现当前页面分享其他页面

    这篇文章主要为大家详细介绍了vue微信分享功能,vue实现当前页面分享其他页面,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-12-12
  • vue实现点击图片放大效果

    vue实现点击图片放大效果

    这篇文章主要为大家详细介绍了vue实现点击图片放大效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-08-08
  • Vue之beforeEach非登录不能访问的实现(代码亲测)

    Vue之beforeEach非登录不能访问的实现(代码亲测)

    这篇文章主要介绍了Vue之beforeEach非登录不能访问的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-07-07

最新评论