赞
踩
[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中定义,或者定义了但是拼写错误,检查拼写。
- <template>
- <footer class="footer" v-if="flag">
- <ul class="filters">
- <li>
- <a
- :class="{ selected: isSel == 'all' }"
- href="javascript:;"
- @click="btn('all')"
- >全部</a
- >
- </li>
- <li>
- <a
- :class="{ selected: isSel == 'no' }"
- href="javascript:;"
- @click="btn('no')"
- >未完成</a
- >
- </li>
- <li>
- <a
- :class="{ selected: isSel == 'yes' }"
- href="javascript:;"
- @click="btn('yes')"
- >已完成</a
- >
- </li>
- </ul>
- </footer>
- </template>
- <script>
- export default {
- props: ["flag", "list"],
- data() {
- return {
- isSel: "all",
- };
- },
- methods: {
- bth(num) {
- this.isSel = num;
- console.log(num);
- },
- },
- };
- </script>
解决方式:找了半天错误,发现我把btn这个函数写成了bth!
救命!家人们!太粗心了!这个错误总结下!下次不能再犯了!!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。