0👍
- Actually load vue.js somewhere.
- App.currentView = ‘guestmenu’.
- Vue is a constructor, you need to call it with
new
. It even yells at you if you forget:[Vue warn]: Vue is a constructor and should be called with the 'new' keyword
- Never mount to or . This is also a console warning!
var GuestMenu = Vue.extend({
template: `
<p>Guest</p>
`});
var UserMenu = Vue.extend({
template: `
<p>User</p>
`});
Vue.component('guestmenu', GuestMenu);
Vue.component('usermenu', UserMenu);
var App = new Vue({
el: '#app',
data:
{
currentView: 'guestmenu'
}
})
App.currentView = 'usermenu'
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<component :is="currentView"> </component>
</div>
Source:stackexchange.com