new Vue({
el: '#app',
data:{
globalVar: 'my variable',
},
methods:{
myGlobalMethods(){
// code
}
}
});
// store.js
export default {
a: 'foo',
b: 'bar'
}
import Vue from 'vue'
import Store from './store'
new Vue({
el: '#app',
data: Store,
render: h => h(App)
})
<template>
<div>{{$root.a}}</div>
</template>
<script>
import Store from './store'
export default {
name: 'app',
methods: {
test () {
this.$root.a = 'something value'
}
}
}
export default {
install(Vue, options) {
Vue.prototype.$myMethod = function (methodOptions) {
console.log('hello from my plugin')
},
Vue.prototype.getPost = () => {
console.log("jnfjknfdjkngkjdfngjkndfjg");
}
}
}
import MyPlugin from './helper'
Vue.use(MyPlugin)
window.globalVar = "I am global";