Home Web Front-end JS Tutorial How to use echarts in Vue.JS

How to use echarts in Vue.JS

Mar 23, 2018 pm 02:53 PM
echarts javascript vue.js

This time I will show you how to use echarts in Vue.JS. What are the precautions for using echarts in Vue.JS? The following is a practical case, let's take a look.

The previous article introduced you to a detailed example of using ECharts in webpack. You can click to view it.

1. Use NPM to install (global import)

Execute the following command:

npm install echarts--save
Copy after login
Introduce echarts module

Introduce the echarts module into the main.js of the Vue project, that is, write the following code:

import echarts from 'echarts'
Vue.prototype.$echarts = echarts;
Copy after login

2. Introduce as needed

The above global import will package all echarts charts, causing the size to be too large. To solve this problem, I can use

requireIntroduce on demand, that is, import whatever is needed:

That is:

let echarts = require('echarts/lib/echarts')
Copy after login
3. Directly quote

globally in the index.html file, use the script tag to introduce

<script src="/static/js/echarts/echarts.js"></script>
Copy after login

Note: write in src The path of echarts;

Then find webpack.base.conf.js in the vue project build directory,

Configuration file, add the externals attribute to the module.exports object, and then configure The path where echarts is located:

module.exports = {
.....
externals: {
// 路径:命名空间
 'echarts/dist/echarts':'echarts',
}
};
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

The server directly obtains the file upload progress

How to use datepicker

Using ejsExcel template in Vue.js

The above is the detailed content of How to use echarts in Vue.JS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use php interface and ECharts to generate visual statistical charts How to use php interface and ECharts to generate visual statistical charts Dec 18, 2023 am 11:39 AM

In today's context where data visualization is becoming more and more important, many developers hope to use various tools to quickly generate various charts and reports so that they can better display data and help decision-makers make quick judgments. In this context, using the Php interface and ECharts library can help many developers quickly generate visual statistical charts. This article will introduce in detail how to use the Php interface and ECharts library to generate visual statistical charts. In the specific implementation, we will use MySQL

How to use map heat map to display city heat in ECharts How to use map heat map to display city heat in ECharts Dec 18, 2023 pm 04:00 PM

How to use a map heat map to display city heat in ECharts ECharts is a powerful visual chart library that provides various chart types for developers to use, including map heat maps. Map heat maps can be used to show the popularity of cities or regions, helping us quickly understand the popularity or density of different places. This article will introduce how to use the map heat map in ECharts to display city heat, and provide code examples for reference. First, we need a map file containing geographic information, EC

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use ECharts and php interface to generate statistical charts How to use ECharts and php interface to generate statistical charts Dec 18, 2023 pm 01:47 PM

How to use ECharts and PHP interfaces to generate statistical charts Introduction: In modern web application development, data visualization is a very important link, which can help us display and analyze data intuitively. ECharts is a powerful open source JavaScript chart library. It provides a variety of chart types and rich interactive functions, and can easily generate various statistical charts. This article will introduce how to use ECharts and PHP interfaces to generate statistical charts, and give specific code examples. 1. Overview of ECha

Does ECharts depend on jQuery? In-depth analysis Does ECharts depend on jQuery? In-depth analysis Feb 27, 2024 am 08:39 AM

Does ECharts need to rely on jQuery? Detailed interpretation requires specific code examples. ECharts is an excellent data visualization library that provides a rich range of chart types and interactive functions and is widely used in web development. When using ECharts, many people will have a question: Does ECharts need to rely on jQuery? This article will explain this in detail and give specific code examples. First, to be clear, ECharts itself does not rely on jQuery;

How to use histogram to display data in ECharts How to use histogram to display data in ECharts Dec 18, 2023 pm 02:21 PM

How to use histograms to display data in ECharts ECharts is a JavaScript-based data visualization library that is very popular and widely used in the field of data visualization. Among them, the histogram is the most common and commonly used chart type, which can be used to display the size, comparison and trend analysis of various numerical data. This article will introduce how to use ECharts to draw histograms and provide code examples. First, we need to introduce the ECharts library into the HTML file, which can be introduced in the following way

How to get HTTP status code in JavaScript the easy way How to get HTTP status code in JavaScript the easy way Jan 05, 2024 pm 01:37 PM

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

ECharts polar scatter plot: how to display data distribution ECharts polar scatter plot: how to display data distribution Dec 18, 2023 pm 03:40 PM

ECharts polar scatter plot: How to display data distribution requires specific code examples Introduction: Data visualization is an important part of data analysis and presentation, and polar scatter plot, as a common data visualization method, can effectively display data The distribution helps us better understand the data. This article will use the ECharts library to implement polar coordinate scatter plots, and introduce how to display data distribution through specific code examples. 1. Introduction to ECharts ECharts is an open source data resource from Baidu.

See all articles