Files
ClassContent/历届学生/朱立伟/2019-04-08/Tabs.js
2024-09-27 02:06:13 +08:00

38 lines
736 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 优势,兼容性好,所有浏览器都认识
// 但是代码复杂
(function(win,doc) {
// 用来做插件的初始化配置
function Tabs (x) {
var name = "zhangs"
if(x.hasOwnProperty("name")) {
this.name = x.name
}else {
console.error("默认参数没有填写请检查")
}
}
Tabs.prototype = {
getUserName: function() {
console.log(this.name)
}
}
win.Tabs = Tabs
})(window,document)
// es6 新的语法糖
// 一般旧的浏览器不支持
// babel 帮你把高版本的js语法转换成低版本浏览器能够认识的语法
// class Tabs{
// constructor(name) {
// this.name = name
// }
// getUserName() {
// console.log(this.name)
// }
// }