VueJS prototype function call inside component

by RomainMazB

HTML

<html>
  <body>
    <div id="app">
    <some-component></some-component>
    <ul ref="fakeConsole">
    </ul>
    </div>
  </body>
</html>

JavaScript

Vue.prototype.newFunction = function(args) {
   // Run some code here
   this.$refs.fakeConsole.innerHTML += '<li>'+args+'</li>';
}

Vue.component('some-component', {
	template: '<input type="text" v-model="arg" @change="callNewFunction()" />',
  data() {
  	return {
    	arg: ''
    }
  },
  methods: {
  	callNewFunction() {
    	this.$root.newFunction(this.arg);
    }
  }
})

const App = new Vue({
	el: '#app',
});