在本地能显示渲染效果,网页不行,
是因为访问方式不一样,
HTML文件直接在浏览器打开和本地服务器localhost打开有什么区别
最直接的区别,很容易注意到,一个是file协议,另一个是http协议。
http访问需要加载静态文件,更改设置
import os
STATIC_URL = '/static/'
#在这里加入
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, 'static/'),
)
由路径,在目录这创建静态文件夹,
最后在html页面直接引入
<meta charset="UTF-8">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<title>功能1</title>
记得加这句
<script src="../static/component/a.js" type="text/javascript"></script>