vue 打包后的 dist 文件下目录是这样的:
python是这样的:
from flask import Flask, render_template
app = Flask(__name__,
static_folder = "./dist",
template_folder = './dist')
@app.route('/')
def index():
return render_template("index.html")
静态文件和 index.html 文件都在同一级下,所以代码里配置的两个路径应该是用一样的吧?
结果报错了
但是如果直接在浏览器打开 dist 里的 index.html 是正常的,这说明静态文件的引入路径应该没有错?static_folder 的值写错了吗?
flask 的静态文件需要你使用 url_for() 函数一个一个的导入。你可以参考一下我的项目
1、https://github.com/eastossifr... 这是蓝图设置的 templates 文件夹和 static 文件夹。
2、https://github.com/eastossifr...
这是一个一个调用静态文件,如 js、css 和 img 文件。