0

我在我的 asp.net 核心 MVC 应用程序中嵌入了缩小的 javascript 和 CSS 文件,并尝试在 razor 视图中显示它。在 node.js 应用程序中,我创建了一个 index.html 调用缩小的 js 和 CSS,它在那里工作正常。但它不适用于 asp.net。下面是代码。

<div style="display: flex">
<div id="jsoneditor1"></div>
<div>
    <div style="float: left;"><button id="copy1">Copy ></button></div>
    <div style="float: left; clear: left;"><button id="copy2">Copy</button></div>
</div>
<div id="jsoneditor2" ></div>
    <link href="~/JSONEditor/jsoneditor.min.css" rel="stylesheet" type="text/css" />
    <script src="~/JSONEditor/jsoneditor.min.js"></script>





    <script>
        // create the editor
        const container1 = document.getElementById("jsoneditor1");

        const options1 = {
            mode: "tree",
            modes: ["code", "tree"], // allowed modes
            onError: function (err) {
                alert(err.toString());
            },
            onModeChange: function (newMode, oldMode) {
                console.log("Mode switched from", oldMode, "to", newMode);
            },
        };
        const editor1 = new JSONEditor(container1, options1);

        // set json
        const initialJson1 = {
            Array: [1, 2, 3, 4],
            Boolean: true,
            Null: null,
            Number: 123,
            Object: { a: "b", c: "d" },
            String: "Hello World",
        };
        editor1.set(initialJson1);

        // get json
        const updatedJson1 = editor1.get();

        //document.getElementById("getJSON").onclick = function () {
        // const json = editor1.get();
        // alert(JSON.stringify(json, null, 2));
        // };
    </script>





    <script>
        // create the editor
        const container2 = document.getElementById("jsoneditor2");

        const options2 = {
            mode: "tree",
            modes: ["code", "tree"], // allowed modes
            onError: function (err) {
                alert(err.toString());
            },
            onModeChange: function (newMode, oldMode) {
                console.log("Mode switched from", oldMode, "to", newMode);
            },
        };
        const editor2 = new JSONEditor(container2, options2);

        // set json
        const initialJson2 = {
            Array: [1, 2, 3, 4],
            Boolean: true,
            Null: null,
            Number: 123,
            Object: { a: "b", c: "d" },
            String: "Hello World",
        };
        editor2.set(initialJson2);

        // get json
        const updatedJson2 = editor2.get();
    </script>

有人可以解释这里的问题是什么吗?使用 asp.net 框架 MVC 的代码。

4

0 回答 0