使用npm命令

一、Element-UI

安装命令

npm install element-ui -S

全局引用

import Vue from 'vue';
import App from './App.vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// use
Vue.use(ElementUI);

new Vue({
     el: '#app',
     render: h => h(App)
});

组件使用

参加官网:https://element.eleme.cn/#/zh-CN/component/installation

二、mavonEditor

安装命令

npm install mavon-editor --save

在main.js中引用

import Vue from 'vue'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
// use
Vue.use(mavonEditor)

new Vue({
     'el': '#main',
     data() {
     // 这个data()可以不写
     return { value: '' }
     }
})

组件使用

在页面中放置:

<mavon-editor v-model="value" />

以上两步结果

三、axios

安装命令

npm install axios --save
npm install vue-axios --save

当然这两句也可以合并成一句:

npm install axios vue-axios --save

在main.js中引用

import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
// use
Vue.use(VueAxios, axios)

组件使用

Vue.axios.get(api).then((response) => {
  console.log(response.data)
})

this.axios.get(api).then((response) => {
  console.log(response.data)
})

this.$http.get(api).then((response) => {
  console.log(response.data)
})

已注销
1 声望2 粉丝