1. It can be implemented using a common parent component;
2. You can set public variables inside;
3. You can also use local storage () and () to achieve it by modifying the local stored values and obtaining the modified values;
4. It is the transmission and modification of props between parent and child components. It should be noted here that the child components cannot directly modify the values accepted in props. An intermediate variable needs to be defined to accept the values in props and modify them. It is passed to the parent component through $emit, that is, this.$emit('checkDisplay',);
5. You can also pass the value query, params through the route,
a. //Jump the page and pass the value
this.$({path:'/index',query:{name:'haha'}}) //Get the passed data this.$
b, or //Jump the page and pass the value
Remember that params can only be redirected with name. If you use path to pass the value, it cannot pass it. Moreover, the value transmitted after refreshing this value transfer page will be cleared.
this.$({name:'index',params:{name:'nana'}}) //Get the passed data this.$
c. You can also directly transfer the value
this.$('/index/'+) //Jump the page and pass the value, but this kind of value transfer prerequisite needs to add "/path/: parameter name" behind the path in the route. this.$.Parameter name //Get data
However, this method will display data in the address bar, which is not safe
6. Pass the value of the path address, what are params and query?
params: /router1/:id , /router1/123, /router1/789 , the id here is called params, and the above method c
query: /router1?id=123 , /router1?id=456 , the id here is called query. Same as above method a
When you use the params method to pass parameters, you need to add parameter names after the route, and when passing parameters, the parameter names must correspond to the parameter names set after the route. There is no such limitation when using the query method, just use it in the jump.
Summarize
The above is the way to pass or modify the values between the two components of vue introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!