靜態(tài)文件:css文件,js文件,圖片等 1,加載靜態(tài)文件使用的是'url_for'函數(shù),然后第一個參數(shù)是‘static’,第二個參數(shù)需要為一個關(guān)鍵字參數(shù)‘filename=‘路徑’。示例: <head> <meta charset="UTF-8"> <title>知了課堂</title> <link rel="stylesheet" href="{{ url_for('static',filename="css/index.css")}}"> <script src="{{ url_for('static',filename='js/index.js') }}"> </script> </head> <body> <img src="{{ url_for('static',filename='img/cheliang.png',alt='') }}"> </body> 路徑查找要以當(dāng)前項目的‘static’目錄作為根目錄。
|