(1)引入第三方插件
代码如下:
import echarts from 'echarts'
(2)引入工具类
1.第一种是引入单个方法
代码如下:
导入:
import {axiosfetch} from './util';
需要export导出:
export function axiosfetch(option){
}
2. 第二种导入成组的方法
代码如下
import * as tools from './libs/tools'
其中tools.js 中有多个export方法,把tools里所有export的方法导入
vue 中怎么用呢?
代码如下:
vue.prototype.$tools = tools
直接用this.$tools.metchod 调用就可以了
(3)说到export 和export default 又有什么区别呢?
1. 先看export
代码如下
import {axiosfetch} from './util';
//需要加花括号,可以一次导入多个也可以一次导入一个,到时要加括号
如果是两个方法
代码如下:
import {axiosfetch,post} from './util';
2. 再是export default
代码如下:
import axiosfetch from './util'; //不需要加花括号,只能一个一个导入
(4)导入css文件
import 'ibiew/dist/style/iview.css';
如果是在.vue 文件中那么在外面套个style
代码如下:
<style>
@import './test.css';
</style>
(5)导入组件
代码如下:
import name1 from './name1'
import name2 from './name2'
components:{
name1,
name2,
}