Vue.js引入echarts、elementUI、museUI、mintUI

不知道怎么建立项目的可以看上一篇

下载elementUI

npm install element-ui -s

下载echarts组件 

npm install echarts --save

 

首先在我们的项目下cmd下载elementUI,下载完成后我们在这个文件下可以查看

 我们在main.js下引用我们下载的

import elementui from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import echarts from 'echarts'
Vue.use(elementui)
Vue.use(echarts)
Vue.prototype.$echarts=echarts

这样我们就可以用了直接上页面

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>
    <ul>
      <li>
        <a
          href="https://vuejs.org"
          target="_blank"
        >
          Core Docs
        </a>
      </li>
      <li>
        <a
          href="https://forum.vuejs.org"
          target="_blank"
        >
          Forum
        </a>
      </li>
      <li>
        <a
          href="https://chat.vuejs.org"
          target="_blank"
        >
          Community Chat
        </a>
      </li>
      <li>
        <a
          href="https://twitter.com/vuejs"
          target="_blank"
        >
          Twitter
        </a>
      </li>
      <br>
      <li>
        <a
          href="http://vuejs-templates.github.io/webpack/"
          target="_blank"
        >
          Docs for This Template
        </a>
      </li>
    </ul>
    <h2>Ecosystem</h2>
    <ul>
      <li>
        <a
          href="http://router.vuejs.org/"
          target="_blank"
        >
          vue-router
        </a>
      </li>
      <li>
        <a
          href="http://vuex.vuejs.org/"
          target="_blank"
        >
          vuex
        </a>
      </li>
      <li>
        <a
          href="http://vue-loader.vuejs.org/"
          target="_blank"
        >
          vue-loader
        </a>
      </li>
      <li>
        <a
          href="https://github.com/vuejs/awesome-vue"
          target="_blank"
        >
          awesome-vue
        </a>
      </li>
    </ul>
<div id="myChart" :style="{width: '300px', height: '300px'}"></div>
  <div>
    <i class="el-icon-edit"></i>
    <i class="el-icon-share"></i>
    <i class="el-icon-delete"></i>
    <el-button type="primary" icon="el-icon-search">搜索</el-button>
  </div>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
   
  methods: {
    drawLine(){
        // 基于准备好的dom,初始化echarts实例
        let myChart = this.$echarts.init(document.getElementById('myChart'))
        // 绘制图表
        myChart.setOption({
            title: { text: '在Vue中使用echarts' },
            tooltip: {},
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'bar',
                data: [5, 20, 36, 10, 10, 20]
            }]
        });
    },
DrawChartright() {
      let Chartright = this.$echarts.init(
        document.getElementById("Chartright")
      );
      // 绘制图表
      Chartright.setOption({
        title: { text: "面积" },
        tooltip: {},
        xAxis: {
          // data: ["类型1", "类型2", "类型3", "类型4", "类型5", "类型6", "类型7"]
          data: this.X_tjlist
        },
        yAxis: {},
        legend: {
          x: "right",
          orient: "vertical",
          // data: ["类型1", "类型2", "类型3", "类型4", "类型5", "类型6", "类型7"]
          data: this.X_tjlist
        },
        series: [
          {
            name: "销量",
            type: "bar",
            // data: [5, 20, 36, 10, 10, 20, 25],
            data:this.Y_tjlist,
            itemStyle: {
              normal: {
                //好,这里就是重头戏了,定义一个list,然后根据所以取得不同的值,这样就实现了,

                color: function(params) {
                  // build a color map as your need.

                  var colorList = [
                    "#32c5e9",
                    "#9fe6b8",
                    "#ffdb5c",
                    "#ff9f7f",
                    "#fb7293",
                    "#e7bcf3",
                    "#8378ea"
                  ];

                  return colorList[params.dataIndex];
                }, //以下为是否显示,显示位置和显示格式的设置了

                label: {
                  show: true,
                  position: "top",
                  formatter: "{b}\n{c}"
                }
              }
            }
          }
        ]
      });
    },
DrawChartleft() {
      let Chartleft = this.$echarts.init(document.getElementById("Chartleft"));
      // 绘制图表
      Chartleft.setOption({
        // title: {
        //   text: "空间数据统计",
        //   x: "left"
        // },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        calculable: true,
        series: [
          {
            name: "数据模式",
            type: "pie",
            radius: [30, 110],
            center: ["75%", "50%"],
            roseType: "area",
            data: [
              { value: 10, name: "类型1", itemStyle: { color: "#32c5e9" } },
              { value: 5, name: "类型2", itemStyle: { color: "#9fe6b8" } },
              { value: 15, name: "类型3", itemStyle: { color: "#ffdb5c" } },
              { value: 25, name: "类型4", itemStyle: { color: "#ff9f7f" } },
              { value: 20, name: "类型5", itemStyle: { color: "#fb7293" } },
              { value: 35, name: "类型6", itemStyle: { color: "#e7bcf3" } },
              { value: 30, name: "类型7", itemStyle: { color: "#8378ea" } }
            ]
          }
        ]
      });
    },
  },
  mounted(){
    this.drawLine();
  },
  
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

出来的效果就是这样的

 

npm install muse-ui -s

import museui from 'muse-ui'
import 'muse-ui/dist/muse-ui.css';
Vue.use(museui)

npm i mint-ui -S

import mintui from 'mint-ui'
import 'mint-ui/lib/style.css'
Vue.use(mintui)

 

 

 

 

 

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

侧耳倾听...

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值