vue相关第三方插件的引用

一、md5的使用
1、下载MD5js
npm install --save js-md5
2、组件里需要使用时,如下:
import md5 from ‘js-md5’;
md5(‘hello’)

二、echars的使用
1、下载echarts
npm install echarts -S
2、全局使用
import echarts from ‘echarts’
Vue.prototype.KaTeX parse error: Expected '}', got 'EOF' at end of input: …myChart = this.echarts.init(dom);
let app = {};
let option = null;
option = this.lineData;
if (option && typeof option === “object”) {
myChart.setOption(option, true);
}
}
3、局部使用
import echarts from “echarts”;
line() {
let id = this.chartId;
let dom = document.getElementById(id);
dom.style.width = this.chartStyle.width;
dom.style.height = this.chartStyle.height;
let myChart = echarts.init(dom);
let app = {};
let option = null;
option = this.chartOption;
if (option && typeof option === “object”) {
myChart.setOption(option, true);
}
}

三、axios的使用
1、下载axios
npm install axios -S
2、使用

import axios from ‘axios’;
Vue.prototype.$axios = axios;

this.$axios({
method: “get”, //指定请求方式
url: “/json/test.json” //请求接口(相对接口,后面会介绍到)
})
.then(function(res) {
console.log(res);
//接口成功返回结果执行
})
.catch(function(err) {
//请求失败或者接口返回失败或者.then()中的代码发生错误时执行
});

四、jquery的使用
1、下载jQuery
npm install jquery -S
2、局部引用
import jquery from ‘jquery’;

mounted(){
jquery("#h1").css({“color”:“red”});
}
3、全局使用
main.js 里添加
import jquery from ‘jquery’;
Vue.prototype.$jquery = jquery;

组件里需要使用的时候,如下调用:
mounted(){
this.$jquery("#h1").css({“color”:“red”});
}

五、ElementUI框架引用
1、下载elementUI
npm install element-ui -S
2、全局使用
main.js 里添加
import ElementUI from ‘element-ui’;
import ‘element-ui/lib/theme-chalk/index.css’; // 默认主题

Vue.use(ElementUI, {
size: ‘small’
});

你可能感兴趣的:(vue)