Open oohira opened 5 years ago
Pinging @sdras
If I'm totally honest, I was confused as well. Mainly because in my code base the syntax was different than what was outlined by @sdras. An example usage in my code base is <div v-my-directive:[dynamicArg]></div>
. That said, I have never had a need to use =dataproperty
to create a statement.
My original goal was to pass a data property to a directive and when that data property changed the directive update hook would get invoked so the directive could react to the change. Doing something like 2) from @oohira's post would not have worked (at least not in my testing).
Here was my original commit: https://github.com/vuejs/vuejs.org/pull/2062/commits/ea850654100ae617005531a692fb287d5d62bbf8
Yep, this was my fault for not reading through more thoroughly. I rewrote this section with clearer examples (thank you for the fiddle @oohira), but also rewrote the explanation to be more conversational in our docs style, and explain the problem space/use case. Let me know if that clears things up for you. Thanks for the issue!
In #2062, an example of dynamic argument for custom directive was added. However, the intension is not clear because
mydirective:[argument]=dataproperty
instead ofmydirective:argument=[dataproperty]
mydirective:argument=dataproperty
instead ofmydirective:argument=[dataproperty]
. But this is already described in the previous examplev-demo:foo.a.b="message"
I think the following example may be close to the original intention.
cc: @bk-dev @sdras