它如何在monaca中使用npm模块“ require”?

时间:2019-05-16 06:48:32

标签: npm module monaca

我尝试在Monaca应用程序中使用npm模块的require("fs")require("csv")。 但是不能使用require,因此Uncaught ReferenceError:require未定义


<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">


    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- 
    <h1>HelloWorld!!!!</h1>
    <a class="button--large" href="phonegap-demo.html">Start Demo</a> -->
    time : <span id="val_slider">0</span><br>
    <input type="number" id="time" value="0" min="0" max="600">
    <input type="button" value="button" onclick="getTimeValue('time');">
    <input type="button" value="軌跡" onclick="lucusFunction('time');">
   <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js"></script>
    <script src="path/to/my/store.legacy.min.js"></script>

    <div class="chart-container" style="position: relative; height:40vh; width:80vw">
        <canvas id="myChart"></canvas>
        <div class="slidecontainer">
            <div id="sliders">
                <input type="range" min="0" max="600" value="0" step="1" class="slider" id="slider" style="width: 100%"></div><br />
        </div>

    </div>

  <script src="components/loader.js"></script>
  <script>

    const ctx = document.getElementById("myChart").getContext('2d');
    const fs = require("fs");
    const csv = require("csv-parse/lib/es5"); 
  </script>
  <script src="phonegap-demo/main.js"></script>
</body>
</html>

错误消息:

Uncaught ReferenceError: require is not defined

0 个答案:

没有答案