htmlのcharsetにutf-8を設定してたのですが、flaskのstaticフォルダにあるjavascriptファイルの日本語が文字化けしてしまいます。(console.log()の結果やinputのvalなどが文字化けされます。)。この現象の原因はなんでしょうか?flaskのversionは1.1.1です。
app.py↓
python
1# -*- coding: utf-8 -*- 2from flask import Flask, session, redirect, render_template 3from flask import request,jsonify 4 5app = Flask(__name__) 6app.config['JSON_AS_ASCII'] = False 7@app.route('/') 8def index(): 9 return render_template("index.html") 10 11@app.route("/favicon.ico") 12def favicon(): 13 return app.send_static_file("favicon.ico") 14 15if __name__ == '__main__': 16 app.run() 17
static配下のindex.js
javascript
1window.onload = function () { 2 console.log("あいうえお");//���������� 3} 4
templates配下のindex.html
html
1<!DOCTYPE html> 2<html lang="ja"> 3 4<head> 5 <meta charset="utf-8"> 6 <link rel="stylesheet" href="static/index.css"> 7 <script type="text/javascript" src="static/jquery-3.1.1.min.js"></script> 8</head> 9 10<body> 11 <p>ここの日本語は文字化けしません。</p> 12 <script type="text/javascript" src="static/index.js" charset="utf-8"></script> 13</body> 14</html> 15

回答1件
あなたの回答
tips
プレビュー