In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to customize instructions in vue. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
In addition to the default core directives (v-model and v-show), Vue also allows you to register custom directives. Note that in Vue2.0, the main form and abstraction of code reuse is components-however, in some cases, you still need to perform underlying operations on pure DOM elements, where custom instructions are used.
This element gets focus when the page loads (note: autofocus doesn't work on mobile Safari). In fact, as long as you haven't clicked anything since you opened the page, the input box should still be in focus. Now let's implement this function with instructions:
/ / register a global custom directive `v-focus`Vue.directive ('focus', {/ / when the bound element is inserted into the DOM. Inserted: function (el) {/ / focus element el.focus ()})
If you want to register a local directive, the component also accepts an option of directives:
Directives: {definition of focus: {/ / instruction inserted: function (el) {el.focus ()}
Then you can use the new v-focus attribute on any element in the template, as follows:
An instruction definition object can provide the following hook functions (all optional):
Bind: called only once, the first time an instruction is bound to an element. One-time initialization settings can be made here.
Inserted: called when the bound element is inserted into the parent node (only the parent node is guaranteed to exist, but not necessarily inserted into the document).
Update: called when the VNode of the component in which it is located is updated, but may occur before its child VNode update. The value of the instruction may or may not have changed. However, you can ignore unnecessary template updates by comparing the values before and after the update (see below for detailed hook function parameters).
ComponentUpdated: called after the VNode and its child VNode of the component to which the instruction belongs are all updated.
Unbind: called only once, when the instruction is unbound from the element.
This is the end of this article on "how to customize vue instructions". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 255
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.