简体   繁体   English

$event.target.value 是 javascript 命令还是 vue.js 命令?

[英]is $event.target.value a javascript command or a vue.js command?

I have this line in my vue.js application我的 vue.js 应用程序中有这一行

<input type="text" v-on:input="cssClass=$event.target.value">

I know that in javascript I can get event.target.value.我知道在 javascript 中我可以获得 event.target.value。 I think that the above code is Vue.js specific code, but I'm not sure.我认为上面的代码是 Vue.js 特定的代码,但我不确定。 Need confirmation.需要确认。

v-on:input will consume the actual DOM event of the input initially, store against $event , a special variable, and then make it available to the function being called. v-on:input input将使用输入的实际 DOM 事件,存储在$event (一个特殊变量)中,然后使其可用于被调用的函数。 In this case you access $event.target.value to get the newly input value from the event.在这种情况下,您访问$event.target.value以从事件中获取新输入的值。 Methods in Inline Handlers 内联处理程序中的方法

Hope that helps.希望有帮助。

You can use $event because of VueJS.由于 VueJS,您可以使用 $event。 Angular2 also has the same special variable. Angular2 也有相同的特殊变量。 What exactly $event object do in Angular 2? $event 对象在 Angular 2 中究竟做了什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM