当前位置:网站首页>Uni app develops wechat applet to dynamically render pages and dynamically change the order of page component modules
Uni app develops wechat applet to dynamically render pages and dynamically change the order of page component modules
2022-06-27 12:24:00 【This is Li Dafu】
uni-app Develop wechat applet to dynamically render pages , Dynamically change the page component module order
List of articles
summary
Although wechat applet provides WXML Templates (template), But for uniapp Doesn't work ,uni-app Develop wechat applet , Does not support <component :is="item" />, at present ( end 2022-05-25) Use flex Layout order To deal with it .
Parent component settings :display: flex;flex-direction: column;; Sub component settings order, The smaller the value, the higher the value , This allows you to change the order of the subcomponents .
Usage method
Change the component name in the core code to the component name in your business , The quantity is added or deleted according to your quantity .
Effect display

Video effects show
uni-app Develop wechat applet to dynamically render pages , Dynamically change page component module
complete demo
Path screenshot

Core components ( Parent component )
<template>
<view>
<view class="box">
<input v-model="haNum" style="visibility: hidden;"/>
<test-one :style="'order:'+orders[0]" />
<test-two :style="'order:'+orders[1]" />
<test-three :style="'order:'+orders[2]" />
</view>
</view>
</template>
<script> import TestOne from "@/components/test-one/index.vue" import TestTwo from "@/components/test-two/index.vue" import TestThree from "@/components/test-three/index.vue" export default {
name:"test", components:{
TestOne, TestTwo, TestThree, }, data() {
return {
haNum:0, orders:[], // Data returned in the background listHome: [ {
title:'test-one', order:3, }, {
title:'test-two', order:1, }, {
title:'test-three', order:2, }, ], }; }, mounted() {
this.getOrder(0,'test-one') this.getOrder(1,'test-two') this.getOrder(2,'test-three') console.log(this.orders) }, methods:{
// Get the sorting value of each module getOrder (v,title){
this.orders[v]=this.listHome.filter((item)=>{
return item.title==title })[0].order this.haNum++ } } } </script>
<style> .box{
display: flex; flex-direction: column; } </style>
Child components 1
<template>
<view>
<view class="">
Test-one
</view>
</view>
</template>
<script> export default {
data() {
return {
}; }, methods:{
} } </script>
Child components 2
<template>
<view>
<view class="">
Test-two
</view>
</view>
</template>
<script> export default {
data() {
return {
}; }, methods:{
} } </script>
Child components 3
<template>
<view>
<view class="">
Test-three
</view>
</view>
</template>
<script> export default {
data() {
return {
}; }, methods:{
} } </script>
If it works , Please click like to collect one key three links, so that more peers can avoid detours , I wish all my friends , No program bug!
边栏推荐
- 【粉丝福利】今天给大家介绍一个白捡钱的方法-可转债,本人亲自验证,每年每人能获利1500元
- . Net6 access skywalking link tracking complete process
- 记一次 .NET 某物管后台服务 卡死分析
- i. Construction of mx6ull C language environment
- [high frequency interview questions] difficulty 1.5/5, LCS template questions
- Minimum editing distance (linear DP writing method)
- nifi从入门到实战(保姆级教程)——身份认证
- 【面试高频题】难度 1.5/5,LCS 模板题
- 自学ADT和OOP
- Configuration of YML
猜你喜欢

Browser cookie to selenium cookie login

TiDB 6.0:让 TSO 更高效丨TiDB Book Rush

How to find the movie and TV clips with the same lines? These 8 movies search for artifact, and find the corresponding segment in one line

How to modify a node_ Files in modules

全球最强截图软件 Snipaste

uni-app开发微信小程序动态渲染页面,动态改变页面组件模块顺序

Comment modifier Node Fichiers dans les modules

alibaba jarslink

【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(二)

Histrix工作原理
随机推荐
Research Report on the overall scale, major manufacturers, major regions, products and application segments of hydraulic torque in the global market in 2022
盘点一些好用且小众的 Markdown 编辑器
面试突击60:什么情况会导致 MySQL 索引失效?
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
Uniapp drop-down layer selection box effect demo (sorting)
log4j. Detailed configuration of properties
如何修改 node_modules 里的文件
JMeter connection DM8
秒云荣获《2022爱分析 · IT运维厂商全景报告》智能运维AIOps市场代表厂商
What's the matter with Amazon's evaluation dropping and failing to stay? How to deal with it?
uni-app开发微信小程序动态渲染页面,动态改变页面组件模块顺序
Basic usage and principle of fork/join framework
微服务拆分
log4j.properties的配置详解
The R language uses the follow up The plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses stress The labels parameter adds label information t
C # WPF realizes undo redo function
mysql学习1:安装mysql
和动态规划的第一次相遇
uniapp下拉弹层选择框效果demo(整理)
Mit6.031 software construction7 reading notesdesigning specifications