JSFiddle - React, Tailwind, and code Playground
JavaScript
var Book = function(id, name, price){
// 私有属性
var num = 1;
// 私有方法
function checkId() {
}
// 特权方法
this.getName = function(){
return this.name;
}
this.getPrice = function() {
return this.price;
}
this.setName = function(name){
this.name = name;
}
this.setPrice = function(price){
this.price = price;
}
// 对象公有属性
this.id = id;
this.name = name;
this.price = price;
// 对象公有方法
this.copy = function(){}
// 构造器(不是太理解这样写的意义)
this.setName(name);
this.setPrice(price);
}
// 静态类公有属性(对象不能访问)
Book.isChinese = true;
// 静态类公有方法(对象不能访问)
Book.resetTime = function(){
console.log('time');
}
Book.prototype = {
// 公有属性
isJsBook:true,
// 公有方法
display: function(){
}
}