首页 > 其他分享 >class介绍初体验

class介绍初体验

时间:2023-02-26 10:02:52浏览次数:32  
标签:初体验 console log price 介绍 class Shouji onePlus brand

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
class Shouji{
// 构造方法 名字不能修改
constructor(brand,price){
this.brand = brand
this.price = price
}
// 方法必须使用该语法,不能使用ES5的对象完整形式
call(){
console.log("我可以打电弧");
}
}

let onePlus = new Shouji("蓝狐",999+'元');
console.log(onePlus);
</script>
</body>
</html>

 

class介绍初体验_构造方法

 



标签:初体验,console,log,price,介绍,class,Shouji,onePlus,brand
From: https://blog.51cto.com/u_15687135/6086014

相关文章