• 西游之路——python全栈——基于BootStrap和Font-Awesome制作页面


    一、制作前的准备

      1、下载BootStrap和Font-Awesome插件

      2、创建static文件夹,并文件夹内进行分类,且把插件放入plugins文件夹

    二、操作流程

      1、创建project        =》day56

      2、APP                  =》app01

      3、配置

          — 静态文件

          —模板路径

      4、models中创建projects表

      5、

        URL    =》    views    =》    HTML

      6、BootStrap

          提供现场样式   +   效果

       FontAwesome

          提供图标

      7、/student/    --->       stuednts函数(班级和学生列表)     --->      student.html

      8、

        $.ajax ({

          url:

          type:

          data:

          success: function()arg {

            //arg一定为字符串,当类似字典时:

                            JSON.parse(arg)       转化为字典

                            JSON.stringify(arg)       转化为字符串

          }

        });

    三、HTML操作

      引入插件 ==》插入模板 ==》引入jQuery并进行绑定 ==》对模板进行编辑

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        {# 引入插件 #}
        <link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.css"/>
        <link rel="stylesheet" href="/static/plugins/font-awesome/css/font-awesome.css"/>
        <style>
            .icon{
                margin: 0px 5px;
            }
        </style>
    </head>
    <body>
    <div class="container">
        <div style="padding:20px 0;">
            <a class="btn btn-primary" id="addBtn">添加</a>
            <a class="btn btn-danger"">删除</a>
        </div>
        <div>
            <table class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>班级</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for row in stu_list %}
                <tr>
                    <td>{{row.id}}</td>
                    <td>{{row.name}}</td>
                    <td>{{row.age}}</td>
                    <td>{{row.gender}}</td>
                    <td>{{row.cs.name}}</td>
                    <td>
                        <a href="" class="glyphicon glyphicon-remove icon"></a>
                        <a href="" class="fa fa-pencil-square-o icon"></a>
                    </td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    
    <!-- Modal -->
    <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">创建学生</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="username" placeholder="姓名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">年龄</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="age" placeholder="年龄">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="1"> 男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="0"> 女
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">班级</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="cs">
                                    {% for row in stu_list %}
                                         <option value="{{row.cs.id}}">{{row.cs.name}}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">保存</button>
                </div>
            </div>
        </div>
    </div>
    
    {# jquery必须放插件前 #}
    <script src="/static/js/jquery-3.1.1.js"></script>
    <script src="/static/plugins/bootstrap/js/bootstrap.js"></script>
    
    <script>
            $(function() {
                bindEvent();
            });
            function bindEvent() {
                $('#addBtn').click(function() {
                    $('#addModal').modal('show');
                })
            }
    </script>
    
    </body>
    </html>
    

      

    四、报错记录

      Unknown command
        未知命令

  • 相关阅读:
    nginx预防常见攻击
    nginx性能优化(针对于高并发量仅供参考,并不是方案)
    nginx平滑升级(1.14--1.15)
    LAMP动静分离安装(源码安装)
    洛谷-P1098 字符串的展开
    洛谷-P1086 花生采摘
    洛谷-P1042 乒乓球
    洛谷-P1031 均分纸牌
    洛谷-P1023 税收与补贴问题
    洛谷-P1125 笨小猴
  • 原文地址:https://www.cnblogs.com/Lujun1028/p/9583984.html
Copyright © 2020-2023  润新知