首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >window.sqlitePlugin未定义-但已安装sqlite

window.sqlitePlugin未定义-但已安装sqlite
EN

Stack Overflow用户
提问于 2019-05-17 22:44:54
回答 1查看 613关注 0票数 1

我试着用cordova-sqlite-storage安装了这个插件https://github.com/xpbrew/cordova-sqlite-storage。我使用framework7。

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

代码语言:javascript
复制
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: routes.js的代码

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2020-04-08 19:41:09

将这段代码添加到index.html中,但要放在任何脚本之前:

代码语言:javascript
复制
<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 -->
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56188777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档