vue.js - 如何侦听作为 vuejs 中对象的道具的更改
问题描述
为什么我的观看对象道具的代码在 vuejs 中不起作用?
我浏览了有关此问题的其他 Q/A 帖子,但没有找到适合我的解决方案。
在我的子组件中,我正在观看这样的过滤器道具......
export default {
name: "ChildComponent",
props: ["list", "searchTerms", "filters"]
watch: {
filters: {
deep: true,
handler: () => {
console.log("filter updated");
if (this.voterLayerActive) {
this.fetchBoundaryBox();
this.createMapWithLeafletAndMapTiler();
}
}
}
在我的父组件中,我像这样传递过滤器道具......
<template> ...<ContactsMap :filters="f"></ContactsMap> ...</template>
<script>
...
export default {
name: "ParentComponent",
data() {
return {
f: {},
...
....
</script>
解决方案
尝试将您的手表处理程序箭头功能替换为:
watch: {
filters: {
deep: true,
handler(){
console.log("filter updated");
if (this.voterLayerActive) {
this.fetchBoundaryBox();
this.createMapWithLeafletAndMapTiler();
}
}
}
推荐阅读
- debugging - 如果 Visual Query 在调试过程中完美运行,但 cshtml 代码无法访问数据,我该如何调试 2sxc 的工作?
- sql-server - How to propagate Always encrypted column encryption to Test, Acceptance and Production?
- macos - How to map memory in DriverKit using IOMemoryDescriptor::CreateMapping?
- parse-platform - 删除 PFObject 上的键的值
- r - Grouping and the adding column to a data.table
- python - 黑盒可能性示例
- javascript - 我的字符串在我的 console.log 中分成多行,但在我的 html 中没有
- c - 在 CLion 上运行调试和构建之间的区别
- java - 下界通配符法
- python - python ipyvuetify 相当于 ipywidgets 输出