当前位置:   article > 正文

如何解决VUE中报错 : Property or method “xxx“ is not defined on the instance but referenced during render_[vue warn]: property or method "submitclick" is no

[vue warn]: property or method "submitclick" is not defined on the instance

如何解决VUE中报错 [Vue warn]: Property or method “xxx” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property

在这里插入图片描述

Vue.component(
    'component1', {
        props: {

        },
        template: ``,
        data:{
            a:"章三",
            b:"李四",
        },
        mounted() {

        },
        methods: {}
    }
)
Vue.component(
    'component2', {
        props: {

        },
        template: ``,
        data() {
            return {
                a:"章三",
                b:"李四",
            }
        },
        mounted() {},
        methods: {}
    }
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

在使用vue组件中,组件要是个函数,即将data作为一个函数名、数据对象作为函数返回值来使用。因为组件可能被用来创建多个实例。如果data仍然是一个纯粹的对象,则所有的实例将共享引用同一个数据对象!通过提供data函数,每次创建一个新实例后,我们能够调用data函数,从而返回初始数据的一个全新副本数据对象

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/315762
推荐阅读
相关标签
  

闽ICP备14008679号