28. WeChat applet (component -- view component case)

WeChat applet (component – ​​view component case)

outline

(1) Slider view container swiper and slider swiper-item components
(2) Small program scroll-view to realize horizontal scrolling navigation
(3) Scroll-view full screen scrolling
(4) Scrolling Tab

view container component

(1) Slider view container swiper and slider swiper-item component
Wechat applet swiper realizes sliding zoom in and out effect

insert image description here

① Write out the basic carousel first, and turn on the seamless connection mode circular

insert image description here
insert image description here
insert image description here
insert image description here
②Enable indicator point
property:
insert image description here

value:
insert image description here
insert image description here

③ Customize the style of the indicator point

insert image description here
insert image description here

④Add front and rear margins

Attributes:

insert image description here
value:
insert image description here

insert image description here

⑤ Set the class name active of the intermediate activation block

insert image description here

insert image description here
insert image description here

⑥ Separately set the active state and normal state styles, and add transition effects

insert image description here
insert image description here
⑦ Add gap
insert image description here

⑧Enable automatic carousel
insert image description here

Write the zoom class carousel steps

①Write out the basic carousel diagram and turn on the seamless connection mode circular
②Open the indicator point
③Customize the indicator point style
④Add front and rear margins ⑤Set
the class name active of the middle activation block
⑥Set the active state and normal state styles separately, and add Transition effect
⑦ Add gap
⑧ Turn on autoplay

(2) Small program scroll-view realizes scrolling navigation

insert image description here

① The small program scroll-view realizes scrolling navigation

insert image description here

② Remove the horizontal scroll bar

Sometimes, the style given by the design diagram does not contain a horizontal scroll bar, so it needs to be removed
insert image description here

③Add the corresponding activation style

insert image description here

data initialization data
insert image description here

④ Add the activation style corresponding to the click

insert image description here

⑤ Solving the problem of some models
Sometimes when you click to switch the state, you will find that some models will have a background, as shown below

insert image description here

Solution: Add -webkit-tap-highlight-color: rgba(0,0,0,0); in wxss

⑥ Dynamically set the position of the horizontal scroll bar

insert image description here

First add the scroll-left attribute to set the initial position of the horizontal scroll bar
insert image description here

Next, add the JS method to set the scroll-view scroll bar to automatically scroll with the click

insert image description here
insert image description here

⑥ Dynamically set the position of the horizontal scroll bar
. After automatic scrolling, it is found that there is no gradient animation effect when scrolling. Add the scroll-with-animation attribute to scroll-view to enable gradient animation.
insert image description here
insert image description here

(2) The small program scroll-view realizes the final effect of scrolling navigation

insert image description here
(3) scroll-view full screen scrolling
Sometimes, in response to customer needs, some pictures need to be full screen scrolling.
Directly setting height: 100 is not very useful, because there is no reference for this height. In the past, the development of web pages was to set the height of the body. Here the applet page rendering container is Page, so first set the height of Page to 100%, and then set the height of scroll-view to 100%, and the problem is solved.
insert image description here
(4) Scroll the Tab tab—order page
Analysis:
order-related tab switching pages: all orders, pending payment, pending delivery, pending receipt, pending evaluation, and refunding

① Realize the switching effect of clicking on the top navigation. When clicking, the corresponding activation will be activated, and the scroll
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
bar will scroll accordingly.
insert image description here

②Set the swiper carousel area under the navigation, focus: the swiper is highly adaptive

insert image description here
insert image description here
insert image description here

③The carousel activation item is associated with the navigation activation item, that is, when the carousel is manually switched and slid, the corresponding activation state of the navigation changes;

insert image description here
insert image description here

At this time, slide the carousel map, and the navigation will also switch when switching

④The carousel activation item is associated with the navigation activation item, that is, when the corresponding option is clicked in the navigation, the bottom carousel is also switched accordingly

Analysis: When clicking the tab button corresponding to the navigation, the carousel below switches to the corresponding display page, where the current attribute of the swiper is needed
insert image description here

④The carousel activation item is associated with the navigation activation item, that is, when the navigation clicks on the corresponding option, the carousel below is also switched accordingly
insert image description here
insert image description here
④The carousel activation item is associated with the navigation activation item

At this time, when sliding the carousel image, the navigation corresponding button will also switch; when the navigation button is clicked, the bottom carousel image display area will also switch
insert image description here

⑤ When switching the carousel, the above navigation can be switched, but the scroll bar does not slide correspondingly, so add the monitoring scroll bar to slide
insert image description here
⑥ So far, when sliding the carousel, the above navigation scroll bar can realize the corresponding scrolling, but the last one When switching back to the first one, the above button cannot correspond
insert image description here

At this point, when you slide down the last page, the navigation button will return to the first page

⑦ At this point, scrolling the Tab tab to switch pages is realized, that is, the two-way binding combination of tab and swiper, which is also one of the common effects

Next, add relevant display information in the swiper display page

⑧Add display information to the swiper display page
insert image description here
insert image description here

⑧Add display information to the swiper display page
insert image description here
insert image description here
⑧Add display information to the swiper display page and render the result
insert image description here

If you have any questions or questions, please leave a message to contact me! ! ! !

Thanks for visiting! ! ! ! !

Guess you like

Origin blog.csdn.net/weixin_45582846/article/details/103452362