以下の内容はhttps://ytyaru.hatenablog.com/entry/2019/05/14/000000より取得しました。


require.jsのプラグインtextでテキストファイルを読み込む方法

 プレーンテキストを扱いたいときに便利。

成果物

コード抜粋

app.js

require.config({
    paths: {
        "require.text": "js/lib/require/plugin/text",
    }
});
require(['require.text!txt/hello.md'], function (txt) {
    alert(txt);
});

ローカル実行時エラー

 ローカルにあるテキストファイルを参照するとエラーになる。ブラウザのセキュリティなので仕方ないのか……。

XMLHttpRequest cannot load file:///tmp/work/JS.require.plugin.text.20180811120000/src/0/txt/hello.md. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.



以上の内容はhttps://ytyaru.hatenablog.com/entry/2019/05/14/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14