Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

js拼接html有没有比较快的方法?

    <div class="formcode clearfix">
        <div class="title">新建用户<div class="xicon">x</div></div>
        <div class="formbox">
            <form action="">
                <p><span><label>* </label>用户名</span><input type="text" placeholder="数字/中英文组合,5-20位字符"></p>
                <p><span><label>* </label>登录密码</span><input type="text"></p>
                <p><span><label>* </label>确认密码</span><input type="text"></p>
                <p><span><label>* </label>员工姓名</span><input type="text"></p>
                <p><span><label>* </label>用户角色</span></p>
                <p><span><label>* </label>联系手机</span><input type="text"></p>
                <div class="tips">用户角色决定用户权限,请到角色管理系统统一设置</div>
                <input type="button" value="保存">
            </form>
        </div>
    </div>

拼接这样一段html 有没有技巧 或者简化方法



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<script id="我是模板" type="text/html">
    <div class="formcode clearfix">
        <div class="title">新建用户<div class="xicon">x</div></div>
        <div class="formbox">
            <form action="">
                <p><span><label>* </label>用户名</span><input type="text" placeholder="数字/中英文组合,5-20位字符"></p>
                <p><span><label>* </label>登录密码</span><input type="text"></p>
                <p><span><label>* </label>确认密码</span><input type="text"></p>
                <p><span><label>* </label>员工姓名</span><input type="text"></p>
                <p><span><label>* </label>用户角色</span></p>
                <p><span><label>* </label>联系手机</span><input type="text"></p>
                <div class="tips">用户角色决定用户权限,请到角色管理系统统一设置</div>
                <input type="button" value="保存">
            </form>
        </div>
    </div>
</script>
<script>
    let _template = document.getElementById('我是模板').innerHTML;
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...