vue 常用插件

富文本编辑器

官方文档

文档描述
在这里插入图片描述

安装

npm i wangeditor --save

使用

<template>
  <div>
    <div id="edit"></div>
  </div>
</template>
<script>
import E from "wangeditor";
export default {
  mounted() {
    const editor = new E("#edit");
    editor.create();
  },
};
</script>
echarts图表

官方文档

在这里插入图片描述
安装

npm i echarts --save

使用

<template>
  <div>
    <div id="main" style="width: 90%; height: 450px; margin: 0 auto"></div>
  </div>
</template>
<script>
var echarts = require("echarts");
export default {
  data() {
    return {
      option: {
        title: {
          text: "用户分布",
          left: "center",
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["北京", "上海", "深圳", "杭州", "其他"],
        },
        series: [
          {
            name: "用户分布",
            type: "pie",
            radius: "55%",
            center: ["50%", "60%"],
            data: [
              { value: 0, name: "北京" },
              { value: 0, name: "上海" },
              { value: 0, name: "深圳" },
              { value: 0, name: "杭州" },
              { value: 0, name: "其他" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      },
    };
  },
  created() {
    this.$API.visitor().then((res) => {
      // console.log(res);
      this.option.series[0].data[0].value = res.data.user_city.beijing;
      this.option.series[0].data[1].value = res.data.user_city.shanghai;
      this.option.series[0].data[2].value = res.data.user_city.shenzhen;
      this.option.series[0].data[3].value = res.data.user_city.hangzhou;
      this.option.series[0].data[4].value = res.data.user_city.qita;
    });
  },
  watch: {
    option: {
      handler(newVal) {
        // console.log(newVal);
        var myChart = echarts.init(document.getElementById("main"));
        myChart.setOption(newVal);
      },
      deep: true,
    },
  },
};
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值