今天写代码的时候遇到这个问题:(他说在这个vue里面找不到我调用的look方法)
一。错误:
BpRecordList.vue:86 [Vue warn]: Property or method "look" 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. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <BpRecordList>
<Anonymous>
<ALayoutContent>
<Anonymous>
<ALayout>
<Anonymous>
<ALayout>
<GlobalLayout> at src/components/page/GlobalLayout.vue
<TabLayout> at src/components/layouts/TabLayout.vue
<ALocaleProvider>
<LocaleReceiver>
<AConfigProvider>
<App> at src/App.vue
<Root>
二。解决方法
如果你确定自己是有调用的这个方法(我这个里面就是指look方法)(我明明定义了look方法,但是报错说没有)的时候,并且你十分确信自己的代码没有错,你可以去看一下自己代码的结构,去看看look方法到底有没有写在<script>标签里面(vue3),或者在没在methods标签里面(vue2),我找了很久错之后看了一下我的代码结构,我发现我的look方法写在了methods标签的外面,所以vue找不到我的look方法,然后报错了。
改正:只需要把look方法挪进methods标签里面就ok了。
谢谢大家可以看到这里,有问题可以私信我~~