elementUI和axios的安装和引入

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()来发起我们的请求了哈。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值