pAddress

功能描述

该插件用于解析拆分收货地址

依赖的插件

快速使用

<div class="address-body">
    <div class="address-input-item">
        <textarea id="address" placeholder="请输入地址"></textarea>
    </div>
    <div class="start-btn" onclick="onStart()">解析</div>
    <div class="res-area">
        <div class="res-item">姓名:<span id="name"></span></div>
        <div class="res-item">手机号:<span id="mobile"></span></div>
        <div class="res-item">电话号码:<span id="phone"></span></div>
        <div class="res-item">省份:<span id="province"></span></div>
        <div class="res-item">市:<span id="city"></span></div>
        <div class="res-item">区:<span id="area"></span></div>
        <div class="res-item">详细地址:<span id="detail"></span></div>
        <div class="res-item">邮编:<span id="code"></span></div>
    </div>
</div>…

原生js function onStart(){var addressInput=$('#address').val();var results=pAddress.parse(addressInput,false);if(results){var addressInfo=results[0];$('#name').text(addressInfo.name);$('#mobile').text(addressInfo.mobile);$('#phone').text(addressInfo.phone);$('#province').text(addressInfo.province);$('#city').text(addressInfo.city);$('#area').text(addressInfo.area);$('#detail').text(addressInfo.details);$('#code').text(addressInfo.zip_code)}}

特别说明

用例见index.html
是否仍需要帮助? 请保持联络!
最后更新于 2024/10/10