Javascript sqlite read DB-使用定位文件引用sql.js库

Javascript sqlite read DB-使用定位文件引用sql.js库,javascript,html,sqlite,sql.js,Javascript,Html,Sqlite,Sql.js,我曾经用它来读取我的数据库,但是这个解决方案已经不起作用了。它现在返回Promise{:“pending”}>。我尝试替换locateFile参数,如下所示: locateFile: file => `dist/${file}` 其中dist是初始目录中的文件夹,但未成功。 完整代码: <html> <head> <script src='dist/sql-wasm.js'></script> <s

我曾经用它来读取我的数据库,但是这个解决方案已经不起作用了。它现在返回
Promise{:“pending”}
>。我尝试替换locateFile参数,如下所示:

locateFile: file => `dist/${file}`
其中dist是初始目录中的文件夹,但未成功。 完整代码:

  <html>
    <head>
      <script src='dist/sql-wasm.js'></script>
      <script type="module">
        const sqlPromise = initSqlJs({
          locateFile: file => `dist/${file}`
        });
        const dataPromise = fetch("http://localhost/jsons/wind_prev.db").then(res => res.arrayBuffer());
        const [SQL, buf] = await Promise.all([sqlPromise, dataPromise])
        const db = new SQL.Database(new Uint8Array(buf));
        console.log(db)

      </script>
    </head>
  </html>

常量sqlPromise=initSqlJs({
locateFile:file=>`dist/${file}`
});
const dataPromise=fetch(“http://localhost/jsons/wind_prev.db)然后(res=>res.arrayBuffer());
const[SQL,buf]=wait Promise.all([sqlPromise,dataPromise])
const db=新的SQL.Database(新的Uint8Array(buf));
控制台日志(db)
我相信这与从
https://sql.js.org/dist
,但我不确定是否可以在本地文件夹中引用它,而无需安装其他软件包

欢迎任何帮助