当前位置: 首页 > news >正文

微信小程序-入门

一.通过   Npm方式下载构建

1.下载和安装Npm:Npm    https://docs.npmjs.com/downloading-and-installing-node-js-and-npm

                    或者     https://nodejs.org/en/download/ 

未安装npm 提示

           以下以安装node安装包为例

 

 

 

 

 

按任意键继续

 

安装完成后 

2. 下载和安装小程序开发工具  :https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
 3.安装使用weui 

https://github.com/wechat-miniprogram/weui-miniprogram

3.1  在小程序根目录下初始化npm

 按以下方式避免npm初始化报错

message: NPM packages not found. Please confirm npm packages which need to build are belong to `miniprogramRoot` directory. Or you may edit project.config.json's `packNpmManually` and `packNpmRelationList`
appid: wxfdcdeefd46e93725
openid: o6zAJs4UHtxoUdwBMYwoYl2bQM9Y
ideVersion: 1.06.2401020
osType: win32-x64
time: 2024-03-07 14:31:03

 

 根目录下初始化

 npm init  -y

 

 安装npm

npm  install 

配置project.config.json文件

    "packNpmManually": true,"packNpmRelationList": [{"packageJsonPath": "./package.json","miniprogramNpmDistDir": "./miniprogram/"}],

 安装小程序weui npm包

npm install --save weui-miniprogram

 

 重新打开此项目

 打开工具菜单=>构建npm

二.通过   useExtendedLib扩展库方式下载构建 

  1.通过微信开发者工具创建项目

  2.配置项目根目录下app.json,添加如下内容:
 "useExtendedLib": {"weui": true},

  3.以官网-progress 进度条实例为例:

      编辑index目录下 index.js

const app = getApp()Page({data: {},onLoad: function () {console.log('代码片段是一种迷你、可分享的小程序或小游戏项目,可用于分享小程序和小游戏的开发经验、展示组件和 API 的使用、复现开发问题和 Bug 等。可点击以下链接查看代码片段的详细文档:')console.log('https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/devtools.html')},
})

   

  编辑index目录下 index.wxml

<progress percent="20" show-info />
<progress percent="40" stroke-width="12" />
<progress percent="60" color="pink" />
<progress percent="80" active />
<progress percent="100" active />

 编辑index目录下 index.wxml


progress {margin: 10px;}

 编译运行即可

  4.以官网-checkbox实例为例:

  编辑index目录下 index.js

Page({data: {items: [{ name: 'USA', value: '美国' },{ name: 'CHN', value: '中国', checked: 'true' },{ name: 'BRA', value: '巴西' },{ name: 'JPN', value: '日本' },{ name: 'ENG', value: '英国' },{ name: 'TUR', value: '法国' },]},checkboxChange: function (e) {console.log('checkbox发生change事件,携带value值为:', e.detail.value)}
})

  编辑index目录下 index.json

{ "componentFramework": "glass-easel" }

  编辑index目录下 index.wxml

<checkbox-group bindchange="checkboxChange"><label class="checkbox" wx:for="{{items}}"><checkbox value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}}</label>
</checkbox-group>

  编辑index目录下 index.wxss

.intro {margin: 30px;text-align: center;
}
page {margin-top: 80px;
}
.checkbox, checkbox {display: flex;flex-direction: row;height: 30px;line-height: 30px;
}
.checkbox {justify-content: center;
}

 编译预览

  5.以官网-input实例为例:

  编辑index目录下 index.js

Page({data: {focus: false,inputValue: '',placeholderStyle: {color:'#F76260'}},onLoad() {// 兼容console.log(this.renderer)if (this.renderer == 'skyline') {this.setData({placeholderStyle: {color:'#F76260'}})} else {this.setData({placeholderStyle: "color:#F76260"})}},bindKeyInput: function (e) {this.setData({inputValue: e.detail.value})},bindReplaceInput: function (e) {var value = e.detail.valuevar pos = e.detail.cursorvar leftif (pos !== -1) {// 光标在中间left = e.detail.value.slice(0, pos)// 计算光标的位置pos = left.replace(/11/g, '2').length}// 直接返回对象,可以对输入进行过滤处理,同时可以控制光标的位置return {value: value.replace(/11/g, '2'),cursor: pos}// 或者直接返回字符串,光标在最后边// return value.replace(/11/g,'2'),},bindHideKeyboard: function (e) {if (e.detail.value === '123') {// 收起键盘wx.hideKeyboard()}}
})

  编辑index目录下 index.js

{ "componentFramework": "glass-easel" }

  编辑index目录下 index.wxml

<view class="page-body"><view class="page-section"><view class="weui-cells__title">可以自动聚焦的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" auto-focus placeholder="将会获取焦点"/></view></view></view><view class="page-section"><view class="weui-cells__title">控制最大输入长度的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" maxlength="10" placeholder="最大输入长度为10" /></view></view></view><view class="page-section"><view class="weui-cells__title">实时获取输入值:{{inputValue}}</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input"  maxlength="10" bindinput="bindKeyInput" placeholder="输入同步到view中"/></view></view></view><view class="page-section"><view class="weui-cells__title">控制输入的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input"  bindinput="bindReplaceInput" placeholder="连续的两个1会变成2" /></view></view></view><view class="page-section"><view class="weui-cells__title">控制键盘的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input"  bindinput="bindHideKeyboard" placeholder="输入123自动收起键盘" /></view></view></view><view class="page-section"><view class="weui-cells__title">数字输入的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" type="number" placeholder="这是一个数字输入框" /></view></view></view><view class="page-section"><view class="weui-cells__title">密码输入的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" password type="text" placeholder="这是一个密码输入框" /></view></view></view><view class="page-section"><view class="weui-cells__title">带小数点的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" type="digit" placeholder="带小数点的数字键盘"/></view></view></view><view class="page-section"><view class="weui-cells__title">身份证输入的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" type="idcard" placeholder="身份证输入键盘" /></view></view></view><view class="page-section"><view class="weui-cells__title">控制占位符颜色的input</view><view class="weui-cells weui-cells_after-title"><view class="weui-cell weui-cell_input"><input class="weui-input" placeholder-style="{{placeholderStyle}}" placeholder="占位符字体是红色的" /></view></view></view>
</view>

.page-body {margin-top: 80px;
}
.page-section{margin-bottom: 20rpx;
}
.weui-input {width: 100%;height: 44px;line-height: 44px;
}

相关文章:

微信小程序-入门

一.通过 Npm方式下载构建 1.下载和安装Npm&#xff1a;Npm https://docs.npmjs.com/downloading-and-installing-node-js-and-npm 或者 https://nodejs.org/en/download/ 未安装npm 提示 以下以安装node安装包为例 按任意键继续 安装完成后 2. 下载和安装小程序开…...

0102全排列和对换-行列式-线性代数

把n个不同的数排成一列&#xff0c;叫做这n个数的全排列&#xff08;排列&#xff09;。 一般情况&#xff0c; 1 , 2 , ⋯ , n 1,2,\cdots,n 1,2,⋯,n是n个数排列的标准次序。 当n个数的任一排列中两个数的先后次序与标准次序不同时&#xff0c;有说有一个逆序。 一个排列中所…...

面向对象的编程语言是什么意思?——跟老吕学Python编程

面向对象的编程语言是什么意思&#xff1f;——跟老吕学Python编程 面向对象是什么意思&#xff1f;面向对象的定义面向对象的早期发展面向对象的背景1.审视问题域的视角2.抽象级别3.封装体4.可重用性 面向对象的特征面向对象的开发方法面向对象程序设计基本思想实现 面向对象的…...

Spring Boot整合MyBatis Plus配置多数据源

Spring Boot 专栏&#xff1a;https://blog.csdn.net/dkbnull/category_9278145.html Spring Cloud 专栏&#xff1a;https://blog.csdn.net/dkbnull/category_9287932.html GitHub&#xff1a;https://github.com/dkbnull/SpringBootDemo Gitee&#xff1a;https://gitee.com/…...

Unix Network Programming Episode 88

‘inetd’ Daemon On a typical Unix system, there could be many servers in existence, just waiting for a client request to arrive. Examples are FTP, Telnet, Rlogin, TFTP, and so on. With systems before 4.3BSD, each of these services had a process associate…...

Java面试题之11MySQL

你对MySQL执行计划怎么看 执行计划就是SQL的执行查询的顺序&#xff0c;以及如何使用索引查询&#xff0c;返回的结果集的行数 在MySQL中&#xff0c;我们可以通过explain命令来查看执行计划。其语法如下&#xff1a; EXPLAIN SELECT * FROM table_name WHERE conditions;在…...

R语言:多值提取到点

ArcGIS中有相关工具实现多值提取到点的功能&#xff0c;在这里&#xff0c;我将使用R语言进行操作&#xff1a; library(dplyr) library(readxl) library(sf) library(raster)setwd("D:/Datasets") Bio <- stack(paste0("D:/Datasets/Data/worldclim2_1km/…...

八股文打卡day27——数据库(4)

面试题&#xff1a;讲一下事务的隔离级别&#xff1f; 我的回答&#xff1a; 因为事务之间的隔离性&#xff0c;造成了一些问题&#xff0c;比如说&#xff1a;脏读、不可重复读和幻读&#xff08;虚读&#xff09;。 1.什么叫脏读&#xff1f; 就是一个事务读取到了另一个事…...

Java桥接模式源码剖析及使用场景

目录 一、介绍二、项目管理系统中使用桥接模式三、权限管理中使用桥接模式四、Java JDBC中使用桥接模式 一、介绍 它的主要目的是将抽象化与实现化分离&#xff0c;使得二者可以独立变化&#xff0c;就像一个桥&#xff0c;将两个变化维度连接起来。各个维度都可以独立的变化。…...

【异常处理】verilator安装时出现异常 make: *** [Makefile:195: verilator_gantt.1] Error 13

在ubuntu中安装verilator工具时执行make出现该报错。 当我出现这个报错的时候我一脸懵逼&#xff0c;因为网上找不到相关解决办法。 后来想到我的verilator是从github上下载zip&#xff0c;然后解压后传到ubuntu上的&#xff0c;windows上解压我记得会把-替换成_&#xff0c;这…...

测试一下 Anthropic 宣称超过 GPT-4 的 Claude 3 Opus

测试一下 Anthropic 宣称超过 GPT-4 的 Claude 3 Opus 0. 引言1. 测试 Claude 3 Opus3. 试用 api key 限制 0. 引言 今天测试一下 Anthropic 发布的 Claude 3 Opus。 3月4日&#xff0c;Anthropic 宣布推出 Claude 3 型号系列&#xff0c;该系列在广泛的认知任务中树立了新的…...

【题解】—— LeetCode一周小结10

【题解】—— 每日一道题目栏 上接&#xff1a;【题解】—— LeetCode一周小结9 4.用栈实现队列 题目链接&#xff1a;232. 用栈实现队列 请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作&#xff08;push、pop、peek、empty&#xff09;&#xff1a…...

Android studio虚拟调试出现“我的APP keeps stopping”问题

问题如图&#xff1a; 遇到这种情况&#xff0c;一看代码&#xff0c;也没有报错呀&#xff0c;怎么不能运行呢&#xff1f;不要慌&#xff01;我们一步一步来。 1、查看Logcat日志 在Android Studio中查看Logcat窗口&#xff0c;可以获取应用程序崩溃时的详细错误信息&…...

【Web】浅聊Java反序列化之Spring2链——两层动态代理

目录 简介 简话JdkDynamicAopProxy 关于target的出身——AdvisedSupport EXP 请确保已阅读过前文或对Spring1链至少有一定认知&#xff1a;【Web】浅聊Java反序列化之Spring1链——三层动态代理-CSDN博客 简介 Spring2 和 Spring1 的反序列化过程基本相同&#xff0c;唯一…...

2386. 找出数组的第 K 大和

2386. 找出数组的第 K 大和 题目链接&#xff1a;2386. 找出数组的第 K 大和 代码如下&#xff1a; //优先队列 //参考&#xff1a;https://leetcode.cn/problems/find-the-k-sum-of-an-array/solutions/2668280/zhao-chu-shu-zu-de-di-k-da-he-by-leetcod-z5kq class Soluti…...

Pytorch学习 day10(L1Loss、MSELoss、交叉熵Loss)

Loss loss的作用如下&#xff1a; 计算实际输出和真实值之间的差距为我们更新模型提供一定的依据&#xff08;反向传播&#xff09; L1Loss 绝对值损失函数&#xff1a;在每一个batch_size内&#xff0c;求每个输入x和标签y的差的绝对值&#xff0c;最后返回他们平均值 M…...

2.2 传统经济学在耍赖

传统经济学中&#xff0c;主体的行为决策是研究的重点对幸福的追求不是传统经济学的研究重点&#xff0c;决策才是。在传统经济学那里&#xff0c;只要能搞清楚是什么决定了决策就可以了。 传统经济学用人们对物品的喜好的排序去替代了对幸福的直接度量。这样做有一个好处&…...

【算法面试题】-04

执行时长 def min_execution_time(n, size, tasks):a 0ans sizei 0while i < size:tmp tasks[i]a tmpif a < n:a 0else:a - ni 1ans a // nif a % n ! 0:ans 1return ans# 读取输入 n int(input()) size int(input()) tasks list(map(int, input().split()))…...

力扣hot100:152.乘积最大子数组(动态规划)

一个子数组问题&#xff0c;我们要使用线性dp&#xff0c;最好先考虑以i结尾&#xff0c;如果定义dp[i]为前i个数最大子数组乘积值 那么dp[i-1]就无法转移到dp[i]。因此我们先考虑dp[i]定义为以第i个数结尾的最大子数组乘积值。 53. 最大子数组和 最大子数组和是一个动态规划问…...

【python 】----Pytest基础知识与进阶知识

定义 用于编写和执行Python测试全功能测试框架(工具),是一个第三方库 安装 pip insatll pytest 安装pytest --version 校验 pytest的组成构成 不写调用语句也可以执行函数内容 在用例运行语句里面: -s:指的是开启与终端的交互,如果没有-s(程序不会输入与打印),一条用…...

51c自动驾驶~合集58

我自己的原文哦~ https://blog.51cto.com/whaosoft/13967107 #CCA-Attention 全局池化局部保留&#xff0c;CCA-Attention为LLM长文本建模带来突破性进展 琶洲实验室、华南理工大学联合推出关键上下文感知注意力机制&#xff08;CCA-Attention&#xff09;&#xff0c;…...

8k长序列建模,蛋白质语言模型Prot42仅利用目标蛋白序列即可生成高亲和力结合剂

蛋白质结合剂&#xff08;如抗体、抑制肽&#xff09;在疾病诊断、成像分析及靶向药物递送等关键场景中发挥着不可替代的作用。传统上&#xff0c;高特异性蛋白质结合剂的开发高度依赖噬菌体展示、定向进化等实验技术&#xff0c;但这类方法普遍面临资源消耗巨大、研发周期冗长…...

如何在最短时间内提升打ctf(web)的水平?

刚刚刷完2遍 bugku 的 web 题&#xff0c;前来答题。 每个人对刷题理解是不同&#xff0c;有的人是看了writeup就等于刷了&#xff0c;有的人是收藏了writeup就等于刷了&#xff0c;有的人是跟着writeup做了一遍就等于刷了&#xff0c;还有的人是独立思考做了一遍就等于刷了。…...

10-Oracle 23 ai Vector Search 概述和参数

一、Oracle AI Vector Search 概述 企业和个人都在尝试各种AI&#xff0c;使用客户端或是内部自己搭建集成大模型的终端&#xff0c;加速与大型语言模型&#xff08;LLM&#xff09;的结合&#xff0c;同时使用检索增强生成&#xff08;Retrieval Augmented Generation &#…...

MinIO Docker 部署:仅开放一个端口

MinIO Docker 部署:仅开放一个端口 在实际的服务器部署中,出于安全和管理的考虑,我们可能只能开放一个端口。MinIO 是一个高性能的对象存储服务,支持 Docker 部署,但默认情况下它需要两个端口:一个是 API 端口(用于存储和访问数据),另一个是控制台端口(用于管理界面…...

LangFlow技术架构分析

&#x1f527; LangFlow 的可视化技术栈 前端节点编辑器 底层框架&#xff1a;基于 &#xff08;一个现代化的 React 节点绘图库&#xff09; 功能&#xff1a; 拖拽式构建 LangGraph 状态机 实时连线定义节点依赖关系 可视化调试循环和分支逻辑 与 LangGraph 的深…...

实战设计模式之模板方法模式

概述 模板方法模式定义了一个操作中的算法骨架&#xff0c;并将某些步骤延迟到子类中实现。模板方法使得子类可以在不改变算法结构的前提下&#xff0c;重新定义算法中的某些步骤。简单来说&#xff0c;就是在一个方法中定义了要执行的步骤顺序或算法框架&#xff0c;但允许子类…...

2025年低延迟业务DDoS防护全攻略:高可用架构与实战方案

一、延迟敏感行业面临的DDoS攻击新挑战 2025年&#xff0c;金融交易、实时竞技游戏、工业物联网等低延迟业务成为DDoS攻击的首要目标。攻击呈现三大特征&#xff1a; AI驱动的自适应攻击&#xff1a;攻击流量模拟真实用户行为&#xff0c;差异率低至0.5%&#xff0c;传统规则引…...

何谓AI编程【02】AI编程官网以优雅草星云智控为例建设实践-完善顶部-建立各项子页-调整排版-优雅草卓伊凡

何谓AI编程【02】AI编程官网以优雅草星云智控为例建设实践-完善顶部-建立各项子页-调整排版-优雅草卓伊凡 背景 我们以建设星云智控官网来做AI编程实践&#xff0c;很多人以为AI已经强大到不需要程序员了&#xff0c;其实不是&#xff0c;AI更加需要程序员&#xff0c;普通人…...

Tauri2学习笔记

教程地址&#xff1a;https://www.bilibili.com/video/BV1Ca411N7mF?spm_id_from333.788.player.switch&vd_source707ec8983cc32e6e065d5496a7f79ee6 官方指引&#xff1a;https://tauri.app/zh-cn/start/ 目前Tauri2的教程视频不多&#xff0c;我按照Tauri1的教程来学习&…...