1π
β
Vue compiles the method definition into Function
instances, which donβt expose their source code as strings. And this.METHODNAME
gets the compiled Function
instance.
However, you could access the original method definition through this.$options.methods.METHODNAME
:
new Vue({
computed: {
showFunction() {
return this.$options.methods.confirm π
}
},
methods: {
confirm() {/*...*/}
}
})
π€tony19
3π
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString
If the toString() method is called on built-in function objects or a function created by Function.prototype.bind, toString() returns a native function string which looks like
"function () {\n [native code]\n}"
Do you have somewhere in your code:
this.confirm = this.confirm.bind(this);
You would need to store the content of the function before binding it.
let myFunction = this.confirm.toString();
this.confirm = this.confirm.bind(this);
π€Pascal
Source:stackexchange.com