vue.js - vue中未定义的testCategories
问题描述
当我加载我的页面时,我的测试类别未定义。如果我在 vue 的挂载部分执行此操作,console.log(this.testCategories);
那么我会得到一个类别数组,但如果我对我的过滤器部分执行此操作,它会给我未定义。
我不明白为什么会这样。
这是我的代码
<template>
<div>
<div class="card mb-4" style="width: 100%;">
<div class="card-body">
<td>{{test.category | testCategory}}</td>
</div>
</div>
</div>
</template>
<script>
export default {
props: ['testCategories'],
data() {
return {
}
},
mounted() {
},
computed: {
},
methods: {
},
filters: {
testCategory(value) {
console.log('testCategories', this.testCategories);
}
},
}
</script>
解决方案
您需要将您的属性更改为test
,它有一个成员category
。或者参考声明的属性testCategories
<theComponent :test='{category:"foobar"}' :testCategory='foobar' />
{
props: ['test', 'testCategory'],
}
推荐阅读
- python - 如何循环几行
- java - 当缓冲区为空时,使用同步缓冲区的 CometD 实现的行为是什么?
- node.js - express js错误 - 发送后无法设置标题
- r - 对多列进行分组并将值带入字符串
- angular - 如何在这个 Angular 应用程序中将文件从 Firebase 存储下载到用户 PC 文件系统?
- dpdk - testpmd:没有探测到的以太网设备消息
- javascript - 如何设置 django-ckeditor 的占位符属性
- python - Selenium chrome 驱动程序 .click() 在特定网站 Python 上不起作用
- symfony - 使用不同的属性多次调用 form_widget - Symfony & Twig
- reactjs - React Native 多转换