I’m sorry in reopen this post, but I’m trying to include Dexie in a cordova project and I don’t know what I’m doing wrong. In app.js I imported deaxi.min.js file and added the Dexie-Test code-lines (see below). The code works fine in the development server. However in the android emulator I get the error.:
Uncaught ReferenceError: Dexie is not defined
at HTMLDivElement. (index.30fc6b88.js:183)
at HTMLDocument.s (index.30fc6b88.js:4)
at Jt.Ro [as trigger] (index.30fc6b88.js:4)
at Mt.pageCallback (index.30fc6b88.js:26)
at _a (index.30fc6b88.js:24)
at f (index.30fc6b88.js:24)
at index.30fc6b88.js:26
at index.30fc6b88.js:26
Should I also import diexie.min.js somewhere else?
//-----------------------------------------------------------------
import $ from ‘dom7’;
import Framework7, { getDevice } from ‘framework7/bundle’;
// Import F7 Styles
import ‘framework7/css/bundle’;
// Import Icons and App Custom Styles
import ‘…/css/icons.css’;
import ‘…/css/app.css’;
// Import Cordova APIs
import cordovaApp from ‘./cordova-app.js’;
// Import Routes
import routes from ‘./routes.js’;
import ‘./dexie.min.js’;
// Import main app component
import App from ‘…/app.f7’;
var device = getDevice();
var app = new Framework7({
name: ‘f7Dexie01’, // App name
theme: ‘auto’, // Automatic theme detection
el: ‘#app’, // App root element
component: App, // App main component
id: ‘io.framework7.myapp’, // App bundle ID
// App routes
routes: routes,
// Input settings
input: {
scrollIntoViewOnFocus: device.cordova && !device.electron,
scrollIntoViewCentered: device.cordova && !device.electron,
},
// Cordova Statusbar settings
statusbar: {
iosOverlaysWebView: true,
androidOverlaysWebView: false,
},
on: {
init: function () {
var f7 = this;
if (f7.device.cordova) {
// Init cordova APIs (see cordova-app.js)
cordovaApp.init(f7);
}
},
},
});
$(document).on(‘page:init’, ‘.page[data-name=“home”]’, function (evt, page) {
var db = new Dexie(“FriendDatabase”);
db.version(1).stores({
friends: “++id,name,age”
});
//
// Manipulate and Query Database
//
db.friends.add({ name: “Josephine”, age: 21 }).then(function () {
return db.friends.where(“age”).below(25).toArray();
}).then(function (youngFriends) {
alert("My young friends: " + JSON.stringify(youngFriends));
}).catch(function (e) {
alert("Error: " + (e.stack || e));
});
})