参考vue实现打印的两种方法:http://www.fly63.com/article/detial/2449?type=1

自己写的demo:

<template>
  <div> 
<div id="printTest" >

      <p>明月照于山间</p>

      <p>清风来于江上 </p>

    </div>

    <el-button v-print="'#printTest'">打印</el-button>
  </div>
</template>
<script>
export default {
  data() {
    return {
    };
  },
};
</script>
<style>
</style>

Echarts:
参考网站:
https://zhuanlan.zhihu.com/p/52121269?utm_source=wechat_session&utm_medium=social&utm_oi=621702477884559360

<template>
  <div id="app">
    <v-chart class="my-chart" :options="option" />
  </div>
</template>
<script>
import ECharts from "vue-echarts/components/ECharts";
import "echarts/lib/chart/pie";
export default {
  name: "App",
  components: {
    "v-chart": ECharts
  },
  data: function() {
    return {
      option: {
        title: {
          text: "某站点用户访问来源",
          subtext: "纯属虚构",
          x: "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: 335, name: "直接访问" },
              { value: 310, name: "邮件营销" },
              { value: 234, name: "联盟广告" },
              { value: 135, name: "视频广告" },
              { value: 1548, name: "搜索引擎" }
            ],
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      }
    };
  }
};
</script>
<style>
.my-chart {
  width: 800px;
  height: 500px;
}
</style>

注意⚠️:引用不同类型就要导入相应的import包;
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐