【问题标题】:window.sqlitePlugin is undefined - but sqlite is installedwindow.sqlitePlugin 未定义 - 但已安装 sqlite
【发布时间】:2019-10-04 22:12:51
【问题描述】:

我已尝试通过cordova-sqlite-storage 安装此插件https://github.com/xpbrew/cordova-sqlite-storage。我用的是framework7。

看起来插件已安装,因为当我再次输入安装命令时,我看到了

C:\Users\User\Desktop\pj>cordova plugin add cordova-sqlite-storage
Plugin "cordova-sqlite-storage" already installed on android.
Plugin "cordova-sqlite-storage" already installed on browser.
Adding cordova-sqlite-storage to package.json

这是我使用 sqlite 的代码: 路由.js

routes = [
  {
    path: '/',
    url: './index.html',
  },
  {
    path: '/drive/',
    url: './pages/drive.html',
    on: {
      pageInit: function (e, page) {
        //db start

          window.sqlitePlugin.echoTest(function() {
            console.log('ECHO test OK');
            alert('ECHO test OK');
          });



          window.sqlitePlugin.selfTest(function() {
            console.log('SELF test OK');
            alert('SELF test OK');
          });

[...]

在控制台中我看到 TypeError: window.sqlitePlugin is undefined

【问题讨论】:

    标签: sqlite cordova cordova-plugins


    【解决方案1】:

    将此添加到您的 index.html, 但在任何脚本之前:

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="plugins/cordova-sqlite-storage/www/SQLitePlugin.js"></script>
    <!-- your other scripts here -->
    

    【讨论】:

      猜你喜欢
      • 2018-03-26
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2015-01-05
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      相关资源
      最近更新 更多