What is the Picker componentCompared with the Select tag on the PC side, the selection box on the mobile side usually pops up at the bottom of the viewPort. Problems with Picker components
Solution Using declarative programming to place the Picker in the Body can better avoid the above two problems. For example, the following method can be used to call the display and hide of the picker this.$picker(component options, { wrapper: { props: {}, on: {} }, props: {}, on: {} }) Option Explanation
Solution Directory Division - Components Describing the Picker containerPicker.vue file function:
The code is as follows: <transition name="slideup"> <div class="picker" v-if="show"> <slot></slot> <div class="mask"></div> </div> </transition> Creating a PickerOutline of ideas
Picker Function
create
Why do we need to get the animation time in requestAnimationFrame instead of getting it directly in mounted? The mounted function of the component is called after the initial rendering, and the Toast component triggers the enter function of the transition by setting showStatus (although the mounted function of the Toast component will be called before, there is no transition class on the toast dom at this time). At this time, the data.setter function is triggered, which distributes and updates the Watcher, causing all operations to be executed in nextTick (that is, microtask), so the calling order is as follows: Toast component Mounted -> parent component Mounted (that is, the Mounted function we are in now. Note that because the transition in toast does not carry the appear attribute, the transition enter function will not be triggered, and thus the transition class will not be added) -> nextTick() -> Toast component update(v-show) -> transition(v-show triggers the enter function) -> toast dom adds the transition class name -> window.getComputedStyle(toast) to get toastDuration, which we can also get in nextTick. Since transition active is present throughout the animation process, and requestAnimationFrame belongs to the browser redraw (painter) hook function, it is executed later than the microtask, so we get it here. show
hide
Why use setTimeout to delete There is a problem with using monitoring transitionend: Vue itself listens to transitionend (or animationend) in the transition component child node removeThe remove function deletes the real DOM, clears the delayer, sets the timer and Picker instances to null, and calls GC updateChildrenComponentAfter the Picker component is completed, it is found that the props in the component are not updated, so a function is written here to manually trigger the update of the component. The component vnode has 4 hook functions. Prepatch is called when updating. There are two values. The first is the last vnode, and the second is the changed vnode. Therefore, we prepatch the original vnode and Component in the PickerCommand function as the old vnode of the diff. Calling this function can update the component. ConclusionThe Picker component is just an example, and more methods can be used to implement it. This is the end of this article about the global call implementation of Vue2.x Picker on mobile terminals. For more relevant Vue2.x Picker global call content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to install and modify the initial password of mysql5.7.18 under Centos7.3
>>: How to use file writing to debug a Linux application
When we add an svg image to display, react prompt...
There are three types of MySQL stored procedure p...
The docker repository itself is very slow, but th...
In this article, we sorted out the startup proces...
Table of contents Install: 1. Basic use of firewa...
Vertical Split Vertical splitting refers to the s...
1. Indexes do not store null values More precisel...
I have seen a lot of MySQL-related syntax recentl...
This article shares the MySQL installation and co...
0. Background Hardware: Xiaomi Notebook Air 13/In...
Table of contents Results at a Glance Heart Effec...
Table of contents Previous words Synchronous and ...
What is pip pip is a Python package management to...
Data sorting asc, desc 1. Single field sorting or...
I just started learning about databases recently....