0
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
工作?
你見過嗎?'? https://www.polymer-project.org/docs/polymer/databinding-advanced.html#autobinding – ebidel 2014-10-04 02:09:04
是的,但在當時不明白它哈哈:)去讀它再次:) PS你的網站應提及「使用元素30s,創建元素5m,構建應用程序30m並理解你在做什麼5年:P – 2014-10-04 02:40:14