Last active
December 30, 2015 11:19
-
-
Save jinwei233/7822062 to your computer and use it in GitHub Desktop.
兼容kissy1.2~1.4的extend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | |
<title>兼容kissy1.2~1.4的extend</title> | |
</head> | |
<body> | |
<!-- 改成1.4.0 进行测试--> | |
<script charset="utf-8" src="http://g.tbcdn.cn/kissy/k/1.3.0/seed.js"></script> | |
<!-- <script type="text/javascript" src="http://a.tbcdn.cn/s/kissy/1.2.0/seed-min.js"></script> --> | |
<script type="text/javascript"> | |
KISSY.use("base",function(S,Base){ | |
var Pie; | |
var methods = { | |
initializer:function(){ | |
console.log('initialized!'); | |
// 访问attrs | |
console.log(this.get("hi")); | |
} | |
} | |
if(Base.extend){ // KISSY 1.4 的 extend | |
Pie = Base.extend(methods); | |
}else{ // KISSY 1.3 的extend | |
Pie = function(cfg){ | |
this.set(cfg); | |
this.initializer(); | |
}; | |
S.extend(Pie,Base,methods); | |
} | |
new Pie({ | |
"hi":"world" | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment