当前位置:网站首页>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!
边栏推荐
- MapReduce principle analysis (in-depth source code)
- mysql学习1:安装mysql
- 动态规划【四】(计数类dp)例题:整数划分
- Dm8: Dameng database - lock timeout
- Go Web 编程入门:验证器
- i. Construction of mx6ull C language environment
- Utilisation de la file d'attente des messages
- Minimum editing distance (linear DP writing method)
- Operators are also important if you want to learn the C language well
- C# wpf 实现撤销重做功能
猜你喜欢
Research Report on the overall scale, major manufacturers, major regions, products and application segments of hydraulic torque in the global market in 2022
Usage of rxjs mergemap
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (II)
How histrix works
TiDB 6.0:让 TSO 更高效丨TiDB Book Rush
秒云荣获《2022爱分析 · IT运维厂商全景报告》智能运维AIOps市场代表厂商
JMeter connection DM8
How to modify a node_ Files in modules
Minimum editing distance (linear DP writing method)
nifi从入门到实战(保姆级教程)——身份认证
随机推荐
Fork/Join 框架基本使用和原理
Topic37——64. 最小路径和
namespace ‘rlang’ 0.2.0 is being loaded, but &gt;= 0.3.0 is required
AI for Science:科研范式、开源平台和产业形态
Thinkphp6 interface limits user access frequency
手把手带你入门 API 开发
.NET6接入Skywalking链路追踪完整流程
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (II)
全球最强截图软件 Snipaste
A brief talk on cordola tree
解压 .log.gz 文件
Topic38——56. Consolidation interval
Comment modifier Node Fichiers dans les modules
MapReduce practical cases (customized sorting, secondary sorting, grouping, zoning)
hibernate操作oracle数据库 主键自增
Microservice splitting
Topic38——56. 合并区间
Raspberry pie 3b+ learning
log4j. Detailed configuration of properties
Four memory areas (stack, heap, global, code area)