Answer the question
In order to leave comments, you need to log in
Global variables in Vue + webpack?
An instance is created in main.js:
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
<script>
import { news, projects } from '../assets/db.json'
export default {
name: 'Home',
data () {
return {
news,
projects
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Hello.
How to add a global property to all instances.
https://ru.vuejs.org/v2/cookbook/adding-instance-p...
import Vue from 'vue';
Vue.prototype.$appName = 'Моё приложение';
...
new Vue({
beforeCreate: function () {
console.log(this.$appName);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question