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
After docker run, the status is always Exited Sol...
Table of contents 1. Encapsulate complex page dat...
The party that creates a new connection is equiva...
Table of contents Overview 1. Define store.js 2. ...
1. Parent div defines pseudo-classes: after and z...
If you have developed DApps on Ethereum, you may ...
How do I download MySQL from the official website...
<br /> This article is translated from allwe...
As shown below: XML/HTML CodeCopy content to clip...
Since the project requires a questionnaire, but th...
The first parameter passing method is dynamic rou...
Table of contents 1. child_process 2. Command exe...
Table of contents 1. What is Set 2. Set Construct...
1. KVM virtual machine migration method and issue...
1. Force no line break and end with an ellipsis. C...