I define a plugin and use it like:
import * as d3 from "d3"
import Vue from "vue"
export default {
install: function(){
window.d3 = d3
Vue.prototype.d3 = d3
}
}
Then when I try to define a component methods using that plugin:
<script>
export default {
methods:{
lineFunction: this.d3.line()
.x(function(d, i) { return i*10; })
.y(function(d) { return d*10; })
.curve(d3.curveMonotoneX)
}
}
}
</script>
It keeps giving me
"Uncaught TypeError: Cannot read property 'line' of undefined"
it seems this.d3 is not ready, I tried use d3 rather than this.d3, both are not working, thoughts?