Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does vue use refs to get values in nested components

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article Xiaobian for you to introduce in detail "vue how to use refs to get the value of nested components", detailed content, clear steps, details handled properly, I hope that this "vue how to use refs to get the value of nested components" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Use refs to get the value of a nested component

Function introduction:

1. The parent component contains zujian1, while zujian1 contains zujian2.

2. Zujian2 binds an input parameter

3. The parent component gets the value in the input box through this.$refs. Component name to get the dom element, multiple layers of nesting, need to be adjusted multiple times

/ / record the benefits of this.inputValue=this.$refs.zujian1.$refs.zujian2.queryvue using ref for the value of the input box

When we need to access the subcomponents directly in JavaScript.

To do this, you can use ref to specify a reference ID for the subcomponent

Var parent = new Vue ({el:'# parent'}) / / access the subcomponent instance var child = parent.$refs.profileconsole.log (child) / /

This is the same as document.getElementById ("profile") for acquiring dom nodes, but using ref reduces the consumption of getting dom nodes.

When ref and v-for are used together, the obtained reference is an array of subcomponents corresponding to the circular data source.

Read this, the "vue how to use refs to obtain the value of nested components" article has been introduced, want to master the knowledge of this article still need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

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: 0

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report