1、工厂模式
//用函数来封装特定接口创建对象细节,抽象创建具体对象的过程
function createProduct(name, price, description) {
let product = new Object()
product.name = name;
product.price = price;
product.description = description;
return product;
}
或
function createProduct(name, price, description) {
return {
name: name,
price: price,
description: description
}
}
var oneYearCard = createProduct('秦桥云阅读年卡', 300, '秦桥云阅读卡,免费畅读一年畅读类书籍')
var oneMonthCard = createProduct('秦桥云阅读月卡', 30, '秦桥云阅读卡,免费畅读一个月畅读类书籍')
网友评论