javascript - Import js file from node_modules in vue-cli app - Stack Overflow

I've installed this with npm : Doing npm install hchs-vue-charts Which is a package to make charts

I've installed this with npm :

Doing npm install hchs-vue-charts

Which is a package to make charts in my views.

I just want to know how to import this lib from node_modules in a single ponent in Vuejs with the Vue-cli app () because in their examples they do it with an instance of Vue.

Thank you

I've installed this with npm : https://github./hchstera/vue-charts

Doing npm install hchs-vue-charts

Which is a package to make charts in my views.

I just want to know how to import this lib from node_modules in a single ponent in Vuejs with the Vue-cli app (https://github./vuejs/vue-cli) because in their examples they do it with an instance of Vue.

Thank you

Share Improve this question asked Nov 23, 2017 at 9:44 MounirOnGithubMounirOnGithub 6993 gold badges10 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

you must install module in main.js

import Vue from 'vue'
import VueCharts from 'hchs-vue-charts'

Vue.use(VueCharts)

then use ponent everywhere in you app, like this:

<template>
  <div id="app">
    <chartjs-line></chartjs-line>
  </div>
</template>

other ponents in lib:

<chartjs-bar/>
<chartjs-horizontal-bar/>
<chartjs-radar/>
<chartjs-polar-area/>
<chartjs-pie/>
<chartjs-doughnut/>

In main.js import vue-charts and init the plugin like this:

import VueCharts from 'hchs-vue-charts'

Vue.use(VueCharts)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743698335a4492136.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信