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 use WeChat Mini Programs template template

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use WeChat Mini Programs template template". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Effect picture

Take the instance home page and list page of MUI as examples

From the figure above, we can see that the list parts of the two pages are very similar, using each row as a unit to make the template.

Template template

1. The location of the template and the location of the page using the template

WXML of the template template

{{item.title}} {{item.title}}

Note: the above creates two templates in the same WXML file, one with an arrow on the right and one without an arrow on the right, identified by the name name.

WXSS of the template template

.tui-menu-list {line-height: 80rpx; color: # 555; font-size: 35rpx; padding: 0 0rpx 0 10px; position: relative;}

Using template templates on index pages

WXML

Introduce templates with import

Using the template, the is attribute of template corresponds to the name attribute in the template, indicating the specific template you want to use. The data attribute is the data to be used in the template. Note that the data structure should be the same.

You can cycle through the template directly, or you can loop on the template plus a layer if necessary.

WXSS

WXSS is introduced to the global situation here!

@ import ". / template/list.wxss"

Directly use import to bring in the WXSS of the list

This code can be placed in the WXSS (index.wxss) of the current page or in the global wxss (app.wxss).

Suggestion: if the project needs to use a large number of templates, WXSS is introduced globally to reduce the amount of code; if the project only uses templates in very few places, you can introduce WXSS in the pages you need.

Using template templates on list pages

WXML

There is no arrow on the right and there are arrow fillets on the right. This is the end of the list of "how to use WeChat Mini Programs template template". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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