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 to solve the problem that the mounted in the Vue sub-component cannot get the value in the props?

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

Share

Shulou(Shulou.com)05/31 Report--

This article Xiaobian introduces in detail for you "Vue sub-component mounted can not get the value of props how to solve", the content is detailed, the steps are clear, the details are handled properly, I hope that this "Vue sub-component mounted can not get the value of props" article can help you solve doubts, the following with Xiaobian's ideas slowly in-depth, together to learn new knowledge.

The subcomponent mounted cannot get the value of props

Problem: passing to the subcomponent to the data is called from the interface, causing the empty object or array to be passed to the subcomponent when the page is created

Method one

Use watch to listen for changes in the median value of props

Method 2 (recommended)

Add v-if judgment when calling subcomponents to determine whether there is data in the array or object.

Component props cannot get a value for the first time, plus sync uses v-if

Remember to define data= in data []

Use watchprops: [data] watch: {date (newValue, oldValue) {if (newValue! = = oldValue) {this.id = this.data [0] .id console.log ('date', this.id)} in sub-components. This is the end of this article on "how to solve the problem that mounted can not get the value in props in Vue sub-components". If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the articles, you are 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