当前位置:   article > 正文

Property or method “btn“ is not defined on the instance but referenced during render. 报错原因及解决措施_button is not defined

button is not defined

 [Vue warn]: Property or method "btn" 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.

报错原因:属性或方法“btn”未在实例上定义,但在渲染过程中被引用。通过初始化该属性,确保该属性在数据选项中或对于基于类的组件是被动的。一般出现这种情况通常是方法未在methods中定义,或者定义了但是拼写错误,检查拼写。

  1. <template>
  2. <footer class="footer" v-if="flag">
  3. <ul class="filters">
  4. <li>
  5. <a
  6. :class="{ selected: isSel == 'all' }"
  7. href="javascript:;"
  8. @click="btn('all')"
  9. >全部</a
  10. >
  11. </li>
  12. <li>
  13. <a
  14. :class="{ selected: isSel == 'no' }"
  15. href="javascript:;"
  16. @click="btn('no')"
  17. >未完成</a
  18. >
  19. </li>
  20. <li>
  21. <a
  22. :class="{ selected: isSel == 'yes' }"
  23. href="javascript:;"
  24. @click="btn('yes')"
  25. >已完成</a
  26. >
  27. </li>
  28. </ul>
  29. </footer>
  30. </template>
  1. <script>
  2. export default {
  3. props: ["flag", "list"],
  4. data() {
  5. return {
  6. isSel: "all",
  7. };
  8. },
  9. methods: {
  10. bth(num) {
  11. this.isSel = num;
  12. console.log(num);
  13. },
  14. },
  15. };
  16. </script>

 解决方式:找了半天错误,发现我把btn这个函数写成了bth!

救命!家人们!太粗心了!这个错误总结下!下次不能再犯了!!!!

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

闽ICP备14008679号