富文本编辑器
安装
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>