Experimenting with Vue.js 2 I've made a little project and trying to import a component, but there's an empty page in a browser. I want to use "extend" in order to try this example: https://jsfiddle.net/xmqgnbu3/1/
So my main.js looks like this:
import Vue from 'vue'
import WorkZone from './components/WorkZone.vue'
import App from './App.vue'
var vm = new Vue({
el: '#app',
components: {
'work-zone': WorkZone,
'app': App
}
});
My App.vue file:
<template>
<div id="app">
<work-zone></work-zone>
</div>
</template>
<script>
import WorkZone from './components/WorkZone.vue';
export default {
name: 'app',
components: {
'work-zone': WorkZone
},
data() {
return {}
},
methods: {}
};
</script>
My WorkZone.vue file:
var WorkZone = Vue.extend({
template: `
<div id="work-zone">
<div id="wrapper"></div>
</div>`,
data() {
return {
tabItems: [{
title: 'Главная страница',
project: 'Текст главная страница',
done: false,
}],
};
},
methods: {
createTab: function(newTab) {
this.tabItems.push(newTab);
}
}
});
The idea is that later there will be a sidebar with buttons. Each button will add an element in a Work-zone or in any other component on a page. I want this function ("function addElem()" for example) to be accessible in any component.