如何用微信小程序写春联

server/2025/2/6 21:46:52/

生活没有模板,只需心灯一盏。 如果笑能让你释然,那就开怀一笑;如果哭能让你减压,那就让泪水流下来。如果沉默是金,那就不用解释;如果放下能更好地前行,就别再扛着。

一、引入 Vant UI

1、通过 npm 安装

npm i @vant/weapp -S --production

​​在这里插入图片描述

2、修改 app.json

将 app.json 中的 “style”: “v2” 去除,小程序的新版基础组件强行加上了许多样式,难以覆盖,不关闭将造成部分组件样式混乱。

3、构建 npm 包

打开微信开发者工具,点击 工具 -> 构建 npm,并勾选 使用 npm 模块 选项,构建完成后,即可引入组件。

在这里插入图片描述

二、页面与功能

1、页面实现

<!--index.wxml-->
<van-cell-group inset><van-cell title="上联" required title-width="3.2em"><input class="weui-input" maxlength="10" placeholder="春联对歌民安国泰" bindinput="onChangeValue1" /></van-cell><van-cell title="下联" required title-width="3.2em"><input class="weui-input" maxlength="10" placeholder="喜字成双花好月圆" bindinput="onChangeValue2" /></van-cell><van-cell title="横批" required title-width="3.2em"><input class="weui-input" maxlength="10" placeholder="国泰民安" bindinput="onChangeValue3" /></van-cell><van-cell required title-width="3.2em" title="字体" is-link value="{{font}}" bind:click="showFontsPopup" /><van-popup show="{{ showFonts }}" bind:close="onFontClose" round position="bottom" custom-style="height: 40%"><van-picker show-toolbar title="春联字体" columns="{{ fontsColumns }}" bind:cancel="onFontCancel" bind:confirm="onFontConfirm" default-index="{{ 0 }}" /></van-popup><van-cell required title-width="3.2em" title="方向" is-link value="{{direction}}" bind:click="showDirectPopup" /><van-popup show="{{ showDirect }}" bind:close="onDirectClose" round position="bottom" custom-style="height: 40%"><van-picker show-toolbar title="字体方向" columns="{{ directionColumns }}" bind:cancel="onDirectCancel" bind:confirm="onDirectConfirm" default-index="{{ 0 }}" /></van-popup></van-cell-group><van-button disabled="{{disabled}}" color="linear-gradient(to right, #FF6034, #EE0A24)" block size="large" bind:click="onSubmit">{{submitText}}</van-button><van-button disabled="{{previewDisabled}}" color="linear-gradient(to right, #4bb0ff, #6149f6)" block size="large" bind:click="onPreviewImage">预览图片</van-button><van-grid column-num="3" border="{{ false }}"><van-grid-item use-slot wx:for="{{localImgUrlArray}}" wx:key="index" bind:click="onImgTap" id="{{index}}" data-imgsrc="{{item}}"><image  style="width: 100%; height: 90px;" src="{{item}}" mode="aspectFit">

http://www.ppmy.cn/server/165508.html

相关文章

Docker 部署 Starrocks 教程

Docker 部署 Starrocks 教程 StarRocks 是一款高性能的分布式分析型数据库&#xff0c;主要用于 OLAP&#xff08;在线分析处理&#xff09;场景。它最初是由百度的开源团队开发的&#xff0c;旨在为大数据分析提供一个高效、低延迟的解决方案。StarRocks 支持实时数据分析&am…

【MyDB】4-VersionManager 之 3-死锁及超时检测

【MyDB】4-VersionManager 之 3-死锁及超时检测 死锁及超时检测案例背景LockTable锁请求与等待管理 addvm调用addputIntoList&#xff0c;isInList&#xff0c;removeFromList 死锁检测 hasDeadLock方法资源释放与重分配 参考资料 死锁及超时检测 本章涉及代码&#xff1a;top/…

【AI编程助手系列】国产AI编程工具 DeepSeek+Cline+VSCode 快速集成

文章目录 前言一、deepseek 介绍二、deepseek 优势三、什么是 Cline&#xff1f;3.1 安装与配置3.1.1 安装 Cline 插件3.1.2 获取 DeepSeek API Key3.1.3 配置 Cline 四、总结 前言 &#x1f916; DeepSeek 是一个强大的 API 平台&#xff0c;提供了丰富的功能和数据&#xff…

Leetcode—1055. 形成字符串的最短路径【中等】Plus

2025每日刷题&#xff08;208&#xff09; Leetcode—1055. 形成字符串的最短路径 实现代码 class Solution { public:int shortestWay(string source, string target) {int ans 0;for(int i 0; i < target.length();) {int prevIdx i;for(int j 0; j < source.len…

从 0 到 1 构建数仓之DWD层

在企业数字化转型进程中&#xff0c;数据仓库的建设至关重要&#xff0c;而 DWD 层&#xff08;明细粒度事实层&#xff09;作为数据仓库的核心支撑层&#xff0c;其搭建质量直接影响企业数据的分析价值与决策效率。本文将结合实际案例与行业经验&#xff0c;详细阐述企业如何从…

【PyQt】pyqt小案例实现简易文本编辑器

pyqt小案例实现简易文本编辑器 分析 实现了一个简单的文本编辑器&#xff0c;使用PyQt5框架构建。以下是代码的主要功能和特点&#xff1a; 主窗口类 (MyWindow): 继承自 QWidget 类。使用 .ui 文件加载用户界面布局。设置窗口标题、状态栏消息等。创建菜单栏及其子菜单项&…

SQL注入漏洞之高阶手法 宽字节注入以及编码解释 以及堆叠注入原理说明

目录 宽字节注入 编码区分 原理 函数 转译符号解释 注意 绕过方式详解 堆叠【Stack】注入攻击 注入语句 宽字节注入 在说宽字节注入之前 我们需要知道编码相关的知识点&#xff0c;这个有助于搞定什么是宽字节注入 分清楚是ascii码是什么宽字节注入代码里面加入了adds…

华为OD机试E卷 --矩阵扩散--24年OD统一考试(Java JS Python C C++)

文章目录 题目描述输入描述输出描述用例题目解析JS算法源码Java算法源码python算法源码c算法源码题目描述 存在一个 m n 的 二维数组 ,其成员取值范围为 0 或 1。 其中值为 1 的成员具备扩散性,每经过 1s,将上下左右值为 0 的成员同化为 1。 二维数组的成员 初始值 都为 0…