小编Phi*_*p C的帖子

如何将一个 svelte 组件的状态绑定到 Sapper 中的查询字符串

我的工兵应用程序围绕一个表组件。这个表组件具有我想在 URL 的查询字符串中表示的状态(偏移量、限制、排序、过滤器等)。

该表目前通过直接更新其状态可以正常工作:

<button on:click="{() => offset += limit}" disabled="{offset + rows.length >= count}">»</button>
Run Code Online (Sandbox Code Playgroud)

我看到有页面只读存储可以让我访问查询字符串的当前值。我想我可以使用类似的东西URLSearchParams来生成更新相关值的链接。

有没有更好的方法来处理这个问题(某种直接将变量绑定到查询字符串的方法)?如果没有,用更新的查询字符串生成链接的最佳方法是什么?

编辑:

我目前的解决方案是以下功能:

<button on:click="{() => offset += limit}" disabled="{offset + rows.length >= count}">»</button>
Run Code Online (Sandbox Code Playgroud)

我在一个a标签中引用了它,将上面的按钮替换为:

href="{getLink({'offset': (offset - limit)})}"
Run Code Online (Sandbox Code Playgroud)

它有效,但我觉得应该有更好的方法

javascript svelte svelte-store sapper

7
推荐指数
1
解决办法
3939
查看次数

在 Windows 上指定 Sequelize sqlite 路径

我一直在 Linux 中使用 Sequelize 和 sqlite3 开发一个 Electron 应用程序,一切都运行良好。我像这样连接到数据库:

new Sequelize("sqlite:" + myPath);
Run Code Online (Sandbox Code Playgroud)

其中 myPath 的形式为“/home/.../someDB.db”

但是,我尝试在 Windows 上运行我的项目并遇到连接到数据库的问题。

如果我使用“someDB.DB”作为 myPath,我可以连接到数据库,但是当 myPath 是“C:...\someDB.db”形式的绝对路径时,我收到错误:

C:\projectPath\node_modules\bluebird\js\release\debuggability.js:868 未处理的拒绝 SequelizeConnectionError: SQLITE_CANTOPEN: 无法在 Database.connections.(匿名函数).lib.Database.err (C:\projectPath\ node_modules\sequelize\lib\dialects\sqlite\connection-manager.js:66:63) printWarning @ C:\projectPath\node_modules\bluebird\js\release\debuggability.js:868 formatAndLogError @ C:\projectPath\node_modules\bluebird \js\release\debuggability.js:593 fireRejectionEvent @ C:\projectPath\node_modules\bluebird\js\release\debuggability.js:618 Promise._notifyUnhandledRejection @ C:\projectPath\node_modules\bluebird\js\release\debuggability.js :64 (匿名) @ C:\projectPath\node_modules\bluebird\js\release\debuggability.js:43 setTimeout (异步) Promise._ensurePossibleRejectionHandled @ C:\projectPath\node_modules\bluebird\js\release\debuggability.js:42 Promise._reject @ C:\projectPath\node_modules\bluebird\js\release\promise.js:658 Promise._settlePromise @C:\projectPath\node_modules\bluebird\js\release\promise.js:584 Promise._settlePromise0 @C: \projectPath\node_modules\bluebird\js\release\promise.js:614 Promise._settlePromises @ C:\projectPath\node_modules\bluebird\js\release\promise.js:689 Async._drainQueue @ C:\projectPath\node_modules\bluebird \js\release\async.js:133 Async._drainQueues @ C:\projectPath\node_modules\bluebird\js\release\async.js:143 Async.drainQueues @ C:\projectPath\node_modules\bluebird\js\release\async .js:17 异步调用计划 @ C:\projectPath\node_modules\bluebird\js\release\schedule.js:18 Async._queueTick @ …

javascript sqlite node.js sequelize.js electron

2
推荐指数
1
解决办法
1936
查看次数