需求需要設置透明漸變區域,在https://gallery.echartsjs.com 中找到如下圖
其中漸變透明色代碼中的color: new echarts 設置完報錯
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(0,150,239,0.3)'
},
{
offset: 1,
color: 'rgba(0,253,252,0)'
}
], false),
原因: main.js中引用了
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
但是在當期頁面中沒引用 需要在頁面中也要把echarts引用進來然後就可以了 import echarts from "echarts"
<script>
import echarts from "echarts" //引用這一句在當前位置
export default {
name: 'home',
data () {
return {
}
},