R
R
Robert Bl2017-08-04 11:39:24
JavaScript
Robert Bl, 2017-08-04 11:39:24

Component method not working?

'use strict';

Vue.component('MainMenu', {
  template: '#Main-menu',
  methods: {
    hover: function( id) {
      console.log(id);
    }
  }
});

let application = new Vue({
  el: '#application'
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robert Bl, 2017-08-04
@Robert_blk

I found a solution, it turns out the problem was that the template wrapper cannot be nested in the application container

E
Evgeny Kulakov, 2017-08-04
@kulakoff Vue.js

I think that it is not correct usage, you need to write a template for the component separately:

<script type="text/x-template" id="main-menu">
  <p>Your template is here</p>
</script>

And then in the main component:
<div id="application">
<main-menu></main-menu>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question