1 引入第三方插件
import echarts from 'echarts'
2 引入工具類
第一種是引入單個方法 import {axiosfetch} from './util'; 下面是寫法,需要export導出 export function axiosfetch(options) { }
第二種 導入成組的方法
import * as tools from './libs/tools' 其中tools.js中有多個export方法,把tools里所有export的方法導入 vue中怎么用呢? Vue.prototype.$tools = tools 直接用 this.$tools.method調用就可以了
說到這 export 和 export default 又有什么區別呢?
下面看下區別
先是 export import {axiosfetch} from './util'; //需要加花括號 可以一次導入多個也可以一次導入一個,但都要加括號 如果是兩個方法 import {axiosfetch,post} from './util'; 再是 export default import axiosfetch from './util'; //不需要加花括號 只能一個一個導入
3.導入 css文件
import 'iview/dist/styles/iview.css';
如果vue文件外面加套style標簽如下
<style> @import './test.css'; </style>
4.導入組件
import name1 from './name1' import name2 from './name2' components:{ name1, name2, },
