my-form
没有iLoadChanged
<my-form iDB="{{iDB}}" iLoad="{{iLoad}}"></my-form>
<catalog-1 iDB="{{iDB}}"></catalog-1>
<my-database iDB="{{iDB}}" iLoad="{{iLoad}}"></my-database>
但是当我将my-database
置于my-form
内时,它确实有用吗?
我的形式
<polymer-element name="my-form" attributes="iDB iLoad">
<template>
...
<my-database iDB="{{iDB}}" iLoad="{{iLoad}}"></my-database>
</template>
<script>
Polymer('my-form', {
iLoad:false,
iDB:null,
iLoadChanged:function(){
console.log('Hello?')
},
我的数据库
<polymer-element name="my-database" attributes="iDB iLoad iDrop">
<script>
Polymer('my-database', {
iDB:null,
iLoad:false,
ready:function(){
var load=function(){
this.iLoad=true
console.log('iLoad',this.iLoad)
}.bind(this)
var request = indexedDB.open("my-database",1);
request.onupgradeneeded = function(e) {
var db = e.currentTarget.result
var store = db.createObjectStore("store", {keyPath: "muts", autoIncrement:false})
//store.createIndex("by_submit", "submit", {unique: false})
console.log('db upgrade', 'v'+db.version)
}
request.onerror = function(e) {
//var db = e.currentTarget.result;
//db.close()
console.error('db error ',e)
}
request.onsuccess = function(e) {
var db = e.currentTarget.result
db.onversionchange = function(e) {
db.close()
console.log('db changed', 'v'+db.version, 'CLOSED')
}
console.log('db setup', 'v'+db.version, 'OK')
load()
}
this.iDB=request
},
iDrop: function () {
this.iDB.result.close()
var req = indexedDB.deleteDatabase(this.iDB.result.name);
req.onsuccess = function() {console.log("Deleted database successfully")}
req.onerror = function() {console.log("Couldn't delete database")}
req.onblocked = function() {console.log("Couldn't delete database due to the operation being blocked")}
}
})
</script>
</polymer-element>
如何让它从外部my-form
开始工作?
答案 0 :(得分:0)
需要使用聚合物包装纸。
<polymer-element name="my-wrapper">
<my-form drawer iDB="{{iDB}}" iLoad="{{iLoad}}"></my-form>
<catalog-1 main iDB="{{iDB}}" page="{{page}}" muts="{{muts}}"></catalog-1>
<my-database iDB="{{iDB}}" iLoad="{{iLoad}}"></my-database>
...