elementUI和axios的安装和引入
elementUI的安装
如果你没有在创建项目的时候安装elementUI。也可以通过命令行的方式安装
项目目录下执行
cnpm install element-ui --save
ZHR:learn zc$ cnpm install element-ui --save
? Installed 1 packages
? Linked 10 latest versions
[1/1] scripts.postinstall element-ui@2.15.3 ? async-validator@1.8.5 ? babel-runtime@6.26.0 ? core-js@^2.4.0 run "node -e \"try{require('./postinstall')}catch(e){}\"", root: "/Users/zc/VueProjects/learn/node_modules/_core-js@2.6.12@core-js"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
[1/1] scripts.postinstall element-ui@2.15.3 ? async-validator@1.8.5 ? babel-runtime@6.26.0 ? core-js@^2.4.0 finished in 80ms
? Run 1 scripts
deprecate element-ui@2.15.3 ? async-validator@1.8.5 ? babel-runtime@6.26.0 ? core-js@^2.4.0 core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
? All packages installed (11 packages installed from npm registry, used 2s(network 2s), speed 987.36kB/s, json 11(100.82kB), tarball 1.46MB)
elementUI的引入
在src下面的main.js下新增如下内容
import Element from 'element-ui'
import "element-ui/lib/theme-chalk/index.css"
Vue.use(Element)
这样我们就可以愉快得在官网上选择组件复制代码到我们项目中直接使用啦。
axios的安装
如果你在创建项目的时候没有安装axios,那也可以使用命令行安装
cnpm install axios --save
ZHR:learn zc$ cnpm install axios --save
? Installed 1 packages
? Linked 1 latest versions
? Run 0 scripts
? All packages installed (2 packages installed from npm registry, used 291ms(network 290ms), speed 33kB/s, json 2(9.57kB), tarball 0B)
axios的引入
在src下面的main.js下新增如下内容
import axios from 'axios'
Vue.prototype.$axios=axios
组件中,我们就可以通过this.$axios.get()来发起我们的请求了哈。
|