yux-storage
Advanced tools
Comparing version 1.2.1 to 2.0.0
{ | ||
"name": "yux-storage", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "yux-storage 是一个基于 HTML5 IndexedDB 封装的 Web 本地数据离线存储库", | ||
"main": "yux-storage.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
@@ -25,12 +25,14 @@ # yux-storage | ||
1. 直接在 [github](https://github.com/yued-fe/yux-storage) 获取 yux-storage.js (推荐) | ||
1. 直接在 [github](https://github.com/yued-fe/yux-storage) 获取 yux-storage.js | ||
```html | ||
<script src="yux-storage.js"></script> | ||
<script type="module" src="yux-storage.js"></script> | ||
``` | ||
> 注意,`script`标签需要添加`type="module"`属性 | ||
2. 直接使用 unpkg [在线链接](https://unpkg.com/yux-storage) | ||
```html | ||
<script src="https://unpkg.com/yux-storage"></script> | ||
<script type="module" src="https://unpkg.com/yux-storage"></script> | ||
``` | ||
@@ -54,2 +56,10 @@ | ||
现在浏览器也可以通过这种方式引入 | ||
```html | ||
<script type="module"> | ||
import yuxStorage from './yux-storage.js' | ||
</script> | ||
``` | ||
在页面中使用 | ||
@@ -131,2 +141,11 @@ | ||
## 多数据库 | ||
默认情况下会创建名为`yux-project`的数据库,如果有多数据库需求,可以通过`YuxDB`自行创建 | ||
```js | ||
import { YuxDB } from 'yuxStorage' | ||
const MyStorage = new YuxDB('test') | ||
``` | ||
## API | ||
@@ -312,4 +331,4 @@ | ||
// 自定义事件的数据在 ev.detail | ||
const [type, detail] = ev.detail; | ||
console.log(type, detail) | ||
const [type, data] = ev.detail; | ||
console.log(type, data) | ||
// ‘setItem’, '{key, value}' | ||
@@ -316,0 +335,0 @@ }) |
@@ -9,3 +9,3 @@ /** | ||
class yuxDB { | ||
export class YuxDB { | ||
@@ -136,6 +136,3 @@ constructor(projectName) { | ||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | ||
module.exports = new yuxDB(); | ||
} else { | ||
window.yuxStorage = new yuxDB(); | ||
} | ||
window.yuxStorage = new YuxDB() | ||
export default window.yuxStorage; |
14041
346
Yes
121