当前位置: 首页 > 工具软件 > WeUI-MiniApp > 使用案例 >

WeUI使用

路和悌
2023-12-01

方法一:

1.先去官网(官方网址:https://weui.io/)==》右键查看源码找到

<link rel="stylesheet" href="./weui.css"/>

点击href后的路径即可进入https://weui.io/weui.css,把所有的css复制到自己本地的weui.css文件中。如果嫌麻烦,也可引入bootcdn线上资源里的css。

2.如果想使用哪块的源码片段,粘贴复制即可。

3.简单引用一下表单提交那里的代码片段

<!DOCTYPE html>
<html>
	<head>
		<head>
		<meta charset="UTF-8">
		<title>WeUI</title>
		<!--必须-->
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
		<!--引入css样式文件(可以自己从网上下载,也可引用bootcdn里网络资源的样式)-->
		<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.css"/>
	</head>
	</head>
	<body>
		<div class="weui-toptips weui-toptips_warn js_tooltips" style="display: none;">错误提示</div>
		<div class="page">
			<div class="page__hd">
				<h1 class="page__title">Input</h1>
				<p class="page__desc">表单输入</p>
			</div>
			<div class="page__bd">
				<div class="weui-cells__title">单选列表项</div>
				<div class="weui-cells weui-cells_radio">
					<label class="weui-cell weui-check__label" for="x11">
		                <div class="weui-cell__bd">
		                    <p>cell standard</p>
		                </div>
		                <div class="weui-cell__ft">
		                    <input type="radio" class="weui-check" name="radio1" id="x11"/>
		                    <span class="weui-icon-checked"></span>
		                </div>
		            </label>
					<label class="weui-cell weui-check__label" for="x12">
		
		                <div class="weui-cell__bd">
		                    <p>cell standard</p>
		                </div>
		                <div class="weui-cell__ft">
		                    <input type="radio" name="radio1" class="weui-check" id="x12" checked="checked"/>
		                    <span class="weui-icon-checked"></span>
		                </div>
		            </label>
					<a href="javascript:void(0);" class="weui-cell weui-cell_link">
						<div class="weui-cell__bd">添加更多</div>
					</a>
				</div>
				<div class="weui-cells__title">复选列表项</div>
				<div class="weui-cells weui-cells_checkbox">
					<label class="weui-cell weui-check__label" for="s11">
		                <div class="weui-cell__hd">
		                    <input type="checkbox" class="weui-check" name="checkbox1" id="s11" checked="checked"/>
		                    <i class="weui-icon-checked"></i>
		                </div>
		                <div class="weui-cell__bd">
		                    <p>standard is dealt for u.</p>
		                </div>
		            </label>
					<label class="weui-cell weui-check__label" for="s12">
		                <div class="weui-cell__hd">
		                    <input type="checkbox" name="checkbox1" class="weui-check" id="s12"/>
		                    <i class="weui-icon-checked"></i>
		                </div>
		                <div class="weui-cell__bd">
		                    <p>standard is dealicient for u.</p>
		                </div>
		            </label>
					<a href="javascript:void(0);" class="weui-cell weui-cell_link">
						<div class="weui-cell__bd">添加更多</div>
					</a>
				</div>
		
				<div class="weui-cells__title">表单</div>
				<div class="weui-cells weui-cells_form">
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label">qq</label></div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入qq号" />
						</div>
					</div>
					<div class="weui-cell weui-cell_vcode">
						<div class="weui-cell__hd">
							<label class="weui-label">手机号</label>
						</div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="tel" placeholder="请输入手机号" />
						</div>
						<div class="weui-cell__ft">
							<button class="weui-vcode-btn">获取验证码</button>
						</div>
					</div>
					<div class="weui-cell">
						<div class="weui-cell__hd"><label for="" class="weui-label">日期</label></div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="date" value="" />
						</div>
					</div>
					<div class="weui-cell">
						<div class="weui-cell__hd"><label for="" class="weui-label">时间</label></div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="datetime-local" value="" placeholder="" />
						</div>
					</div>
					<div class="weui-cell weui-cell_vcode">
						<div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="number" placeholder="请输入验证码" />
						</div>
						<div class="weui-cell__ft">
							<img class="weui-vcode-img" src="https://weui.io/images/vcode.jpg" />
						</div>
					</div>
				</div>
				<div class="weui-cells__tips">底部说明文字底部说明文字</div>
		
				<div class="weui-cells__title">表单报错</div>
				<div class="weui-cells weui-cells_form">
					<div class="weui-cell weui-cell_warn">
						<div class="weui-cell__hd"><label for="" class="weui-label">卡号</label></div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="number" pattern="[0-9]*" value="weui input error" placeholder="请输入卡号" />
						</div>
						<div class="weui-cell__ft">
							<i class="weui-icon-warn"></i>
						</div>
					</div>
				</div>
		
				<div class="weui-cells__title">开关</div>
				<div class="weui-cells weui-cells_form">
					<div class="weui-cell weui-cell_switch">
						<div class="weui-cell__bd">标题文字</div>
						<div class="weui-cell__ft">
							<input class="weui-switch" type="checkbox" />
						</div>
					</div>
					<div class="weui-cell weui-cell_switch">
						<div class="weui-cell__bd">兼容IE Edge的版本</div>
						<div class="weui-cell__ft">
							<label for="switchCP" class="weui-switch-cp">
		                        <input id="switchCP" class="weui-switch-cp__input" type="checkbox" checked="checked"/>
		                        <div class="weui-switch-cp__box"></div>
		                    </label>
						</div>
					</div>
				</div>
		
				<div class="weui-cells__title">文本框</div>
				<div class="weui-cells">
					<div class="weui-cell">
						<div class="weui-cell__bd">
							<input class="weui-input" type="text" placeholder="请输入文本" />
						</div>
					</div>
				</div>
		
				<div class="weui-cells__title">文本域</div>
				<div class="weui-cells weui-cells_form">
					<div class="weui-cell">
						<div class="weui-cell__bd">
							<textarea class="weui-textarea" placeholder="请输入文本" rows="3"></textarea>
							<div class="weui-textarea-counter"><span>0</span>/200</div>
						</div>
					</div>
				</div>
		
				<div class="weui-cells__title">选择</div>
				<div class="weui-cells">
		
					<div class="weui-cell weui-cell_select weui-cell_select-before">
						<div class="weui-cell__hd">
							<select class="weui-select" name="select2">
								<option value="1">+86</option>
								<option value="2">+80</option>
								<option value="3">+84</option>
								<option value="4">+87</option>
							</select>
						</div>
						<div class="weui-cell__bd">
							<input class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入号码" />
						</div>
					</div>
				</div>
				<div class="weui-cells__title">选择</div>
				<div class="weui-cells">
					<div class="weui-cell weui-cell_select">
						<div class="weui-cell__bd">
							<select class="weui-select" name="select1">
								<option selected="" value="1">微信号</option>
								<option value="2">QQ号</option>
								<option value="3">Email</option>
							</select>
						</div>
					</div>
					<div class="weui-cell weui-cell_select weui-cell_select-after">
						<div class="weui-cell__hd">
							<label for="" class="weui-label">国家/地区</label>
						</div>
						<div class="weui-cell__bd">
							<select class="weui-select" name="select2">
								<option value="1">中国</option>
								<option value="2">美国</option>
								<option value="3">英国</option>
							</select>
						</div>
					</div>
				</div>
		
				<label for="weuiAgree" class="weui-agree">
		            <input id="weuiAgree" type="checkbox" class="weui-agree__checkbox"/>
		            <span class="weui-agree__text">
		                阅读并同意<a href="javascript:void(0);">《相关条款》</a>
		            </span>
		        </label>
		
				<div class="weui-btn-area">
					<a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">确定</a>
				</div>
			</div>
			<div class="page__ft" style="text-align: center;">
				<a href="javascript:home()"><img src="https://weui.io/images/icon_footer_link.png" style="height: 19px;"/></a>
			</div>
		</div>
		
		
		<!--引入zepto,因为在后续的过程中会用到jq,zepto中集成了jq-->
		<script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.js" type="text/javascript" charset="utf-8"></script>
		
		<!--引入微信的两个js-->
		<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<!--weui.min.js有版本之分,在低版本的js中有些功能不完善,在高版本会支持-->
    	<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
    	<!--<script src="https://res.wx.qq.com/open/libs/weuijs/1.1.4/weui.min.js"></script>-->
    	
    	<!--zepto必须在自己的js代码之前引入-->
		<script type="text/javascript">
			
			$(function(){
		        var $tooltips = $('.js_tooltips');
		
		        $('#showTooltips').on('click', function(){
		            if ($tooltips.css('display') != 'none') return;
		
		            // toptips的fixed, 如果有`animation`, `position: fixed`不生效
		            $('.page.cell').removeClass('slideIn');
		
		            $tooltips.css('display', 'block');
		            setTimeout(function () {
		                $tooltips.css('display', 'none');
		            }, 2000);
		        });
		    });
			
			
		</script>
	</body>
</html>

方法二:

    安装git,通过git装,详情请参考https://github.com/Tencent/weui.js

几点说明:

也可以参考:https://www.jianshu.com/p/6c8e55fc501b

 类似资料: