解决
nodejs安装后,在安装目录下【nodejs】创建两个文件夹【node_global】及【node_cache】用来配置全局环境变量。
之后,打开cmd命令窗口,输入
npm config set prefix ”D:\Program Files\nodejs\node_global”
npm config set cache “D:\Program Files\nodejs\node_cache”
bug记录:
<el-menu router :default-active="this.$route.path" mode="horizontal">
<el-menu-item index="/set">页面1</el-menu-item>
<el-menu-item index="/calculation">页面2</el-menu-item>
<el-menu-item index="/edit">页面3</el-menu-item>
</el-menu>
<!-- slot="trigger" -->
<el-upload class="upload" action="http://192.168.222.22:8074/import/upload" :headers="headers" :limit="1" ref="upload" :on-exceed="handleExceed" :file-list="fileList" :on-success="uploadSuccess" :before-upload="beforeAvatarUpload" accept="files">
<i :class="{ 'add_icon': data.id !== null && data.isDirectory == 1 }" slot="trigger" size="small" type="primary"></i>
</el-upload>
1. :default-expand-all="defaultExpand" :filter-node-method="filterNode"
2. defaultExpand: false,
3. filterNode(filterText, data) {
if (filterText) {
this.defaultExpand = true
this.changeTreeNodeStatus(this.$refs.tree.store.root)
return true
} else {
this.defaultExpand = false
this.changeTreeNodeStatus(this.$refs.tree.store.root)
}
return data.name.indexOf(filterText) !== -1;
},
changeTreeNodeStatus(node) {
console.log(node)
node.expanded = this.defaultExpand
for (let i = 0; i < node.childNodes.length; i++) {
// 改变节点的自身expanded状态
node.childNodes[i].expanded = this.defaultExpand
// 遍历子节点
if (node.childNodes[i].childNodes.length > 0) {
this.changeTreeNodeStatus(node.childNodes[i])
}
}
},
4. watch: {
filterText(filterText) {
console.log(filterText);
this.$refs.tree.filter(filterText);
},
},
handleChartClick(params) {
// 处理饼状图点击事件的逻辑
console.log('点击了饼状图', params)
// 获取点击区域的颜色
const color = params.color
// 更新选中的颜色
// this.selectedColor = color
console.log(this.showPicker)
// 弹出颜色选择器
this.showPicker = true
console.log(this.showPicker)
// this.selectedColor = color
// const containerRect = this.$refs.chart.getBoundingClientRect()
// const index = params.dataIndex
// const pieRect = this.getPieRect(index)
// const pickerWidth = 560
// const pickerHeight = 400
// const pickerLeft = containerRect.left + (pieRect.x2 + pieRect.x4) / 2 - pickerWidth / 2
// const pickerTop = containerRect.top + (pieRect.y2 + pieRect.y4) / 2 - pickerHeight / 2
// this.pickerStyle = {
// left: pickerLeft + 'px',
// top: pickerTop + 'px'
// }
},
getPieRect(index) {
const chartInstance = echarts.getInstanceByDom(this.$refs.chart)
const series = chartInstance.getOption().series[0]
// console.log(series)
const dataIndex = series.data[index].name
const angle = 2 * Math.PI / series.data.length
const startAngle = -Math.PI / 2 + index * angle
const endAngle = startAngle + angle
const radius = Math.min(chartInstance.getWidth(), chartInstance.getHeight()) / 2
const centerX = chartInstance.getWidth() / 2
const centerY = chartInstance.getHeight() / 2
const outerRadius = radius - 10
const innerRadius = 0
const x1 = centerX + outerRadius * Math.cos(startAngle)
const y1 = centerY + outerRadius * Math.sin(startAngle)
const x2 = centerX + innerRadius * Math.cos(startAngle)
const y2 = centerY + innerRadius * Math.sin(startAngle)
const x3 = centerX + innerRadius * Math.cos(endAngle)
const y3 = centerY + innerRadius * Math.sin(endAngle)
const x4 = centerX + outerRadius * Math.cos(endAngle)
const y4 = centerY + outerRadius * Math.sin(endAngle)
console.log(x1, y1, x2, y2, x3, y3, x4, y4)
return { x1, y1, x2, y2, x3, y3, x4, y4 }
},
解决:思路2:获取到数据点击具体色块的位置计算中心点,
updatePicker(val) {
document.getElementById('charts').removeEventListener('mousemove', this.handleMouseMove)
console.log(222, val, '新颜色=', val.hex)
// 使用 $set 方法来更新数组中指定索引的元素 this.$set(this.colors, this.dataIndex, val.hex);
// this.$set(this.colors, this.dataIndex, val.hex);
const colindex = this.dataIndex
const newcolor = val.hex
this.colors.splice(colindex, 1, newcolor);
this.$forceUpdate();
this.generateChart()
// this.colors[this.dataIndex] = val.hex
},