provide any channel to watch props change in directive
<div v-custom-dir="{ a }"></div>
app.directive("custom-dir", {
// support `props`
props: ["a"],
// add `props` arguments when mounted or provide setup hook
mounted(props) {
// watch props change
watch(() => props.a, console.log)
}
})
l know using component can resolve it,but l need to modify DOM,it will append an extra node,and change it's behavior when props was changed
now l depend on update hook,it will emit when parent updated
app.directive("custom-dir", {
update(el, { value }){
if(value.a === "b"){
// do something
}
}
})
Is there any other way?