vue3文档学习笔记

Last Updated:

2022-08-12

指令(directive)

指令的参数(arguments)

动态指令

<!--
Note that there are some constraints to the argument expression,
as explained in the "Dynamic Argument Value Constraints" and "Dynamic Argument Syntax Constraints" sections below.
-->
<a v-bind:[attributeName]="url"> ... </a>

<!-- shorthand -->
<a :[attributeName]="url"> ... </a>
<a v-on:[eventName]="doSomething"> ... </a>

<!-- shorthand -->
<a @[eventName]="doSomething">

动态指令的值的限制 (Dynamic Argument Value Constraints)

必须为非空字符串。除了null之外的其他非字符串的值,都会报warning

Dynamic arguments are expected to evaluate to a string, with the exception of null. The special value null can be used to explicitly remove the binding. Any other non-string value will trigger a warning.

指令的总结图

20220809-vue3-directive.69c37117.png