用uniapp写一个瀑布流
时间: 2023-05-23 12:01:11 浏览: 190
表格
这是一个表格。| 第一行 | 第二行 | 第三行 | |--------|--------|--------| | 第一列 | 第二列 | 第三列 |
下面是用UniApp实现瀑布流的示例代码:
<template>
<div class="waterfall">
<div v-for="(item, index) in list" :key="index" :style="{height: item.height + 'px'}">{{ item.content }}</div>
</div>
</template>
<script>
export default {
data() {
return {
list: [
{ content: '这是第1条数据', height: 100 },
{ content: '这是第2条数据', height: 150 },
{ content: '这是第3条数据', height: 120 },
{ content: '这是第4条数据', height: 130 },
{ content: '这是第5条数据', height: 110 },
{ content: '这是第6条数据', height: 140 },
]
}
}
}
</script>
<style>
.waterfall {
column-count: 3; /*设置列数为3*/
column-gap: 10px; /*设置列之间的间隔*/
width: 100%; /*宽度自适应*/
}
.waterfall div {
margin: 10px 0; /*每个格子的上下间隔*/
background: #f5f5f5; /*背景颜色*/
padding: 10px; /*格子内边距*/
}
</style>
对于中文加密,可以使用以下代码进行加密:
function encrypt(str) {
var result = '';
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
if (c >= 0x4e00 && c <= 0x9fa5) { /*判断是否为汉字*/
result += String.fromCharCode(c + 3); /*汉字加密方式为加3*/
} else {
result += str.charAt(i);
}
}
return result;
}
而对于lua closure factory,可以参考以下代码:
function createClosure(a)
return function() return a end
end
local closure = createClosure("Hello World!")
print(closure()) --输出: Hello World!