通过单击事件在同一组件中的按钮上调用组件方法,但未在实例上定义

时间:2017-04-06 21:47:12

标签: javascript vue.js vuejs2

当我按相应的按钮时,为什么greet会返回[Vue warn]: Property or method "greet" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in <Inputs>)

 <template id="input-template">
           ...
   <div v-for="(inputs, inputName) in renderedSystemComponent">
      <button v-on:click="greet">Greet</button>
  ...
 </template>    


Vue.component('inputs', {
    template: '#input-template',

    props: ['systemComponents','selectedSystemProductComponents'],

    data () {
        return {
            renderedSystemComponent: [],

        }
    },
    methods: {
        greet: function () {
            alert('Hello ');
        }
    },
    watch: {
        selectedSystemProductComponents: function() {
          ...
        }
    },
});

0 个答案:

没有答案