現在jsのimport、exportを勉強しているところです。
ひとまず動作を確かめたいので、以下のような構成を作って実験をしてみました。
>tesmod.js export const tes = "xyz"; >importing.js import {tes} from "/app_static/js/tesmod.js"; console.log("importing"); >html <script type="module" src="/app_static/js/importing.js"></script> >サーバー(bottle) @route('/app_static/<rel_path:path>') def server_static(rel_path): res = static_file(rel_path, root=APP.static_dir) return res
以上のようにしたところ、正常に読み込みがなされません。
ブラウザはchromeです。
Networkで確認したところ、importing.js
がpending
のまま進行していませんでした。
(404エラーなどは出ません。)
どこがまずいのでしょうか。
教えていただけると助かります。
よろしくお願いいたします。
(よくある記述と違う点として、相対パスではなく /app_static/js/tesmod.js
といった書き方になっています。ただ、相対パスだと404エラーになるので、サーバーが認識するパスに書き換えました。こういう点も影響するのでしょうか?)
あなたの回答
tips
プレビュー