I have a vue app that I wish to build as a component so I can use it in another app (non-vue).
I'm using the vue-cli to build:
vue-cli-service build --target wc --name my-component 'src/App.vue'
I'm having two issues:
1. When vue-cli compiles the code, I noticed 'this' is getting changed:
In my original code, search method does not use function
and so this is not overwritten.
search(id) {
// this is not overwritten
console.log(this.myProp)
Here is the same function in the compiled build:
Notice they cached this with: var _this = this
, however, all my references to this
are not changed to _this
!
Am I crazy or is this not a huge issue? I'm having to do messy workarounds to get my code to work because of this.
stumped :\