Answer the question
In order to leave comments, you need to log in
How to pass event to application?
In main.js:
import player from './package/Player';
Vue.use(player);
...
new Vue({
el: '#app',
player,
export default function (Vue) {
let isPlaying = true;
Vue.player = {
changePlaying(){
let before = isPlaying;
isPlaying = !isPlaying;
let after = isPlaying;
console.log(before, after);
},
getPlaying(){
return isPlaying;
}
};
Object.defineProperties(Vue.prototype, {
$player:{
get: () => {
return Vue.player;
}
}
});
}
computed:{
player(){
return this.$player.getPlaying();
}
},
true false
false true
true false
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question