我对SQlite3和Vue2有问题
我正在使用Electron-Vue,我已经安装了SQLite3并且要求它成功(database.db)
使用:
db.serialize(function() {
db.run("CREATE TABLE lorem (info TEXT)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();
var rows = document.getElementById("database");
db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
var item = document.createElement("li");
item.textContent = "" + row.id + ": " + row.info;
rows.appendChild(item);
});
});
db.close();
那么下一步对我来说很困难(Basic Crud System)?
如何像此代码一样添加到Vue组件
<table>
<thead>
<th>
<td>Number</td>
<td>Name</td>
<td>Content</td>
</th>
<thead>
<tbody>
<tr ng-repeat="item in ctrl.items | filter : ctrl.filterOnNameAndNumber">
<td>{{item.number}}</td>
<td>{{item.name}}</td>
<td>{{item.content}}</td>
</tr>
</tbody>
</table>
ctrl.filterOnNameAndNumber = function (item) {
// filter logic here
return item.name.indexOf(ctrl.search) > -1 || item.number === ctrl.search;
}
只需一个简单的演示代码即可开始使用VueJS2 Component和SQlite3 !!