对象属性定义方法
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>对象属性定义方法</title>
</head>
<body>
<ul>
<li id="first">1</li>
<li>2</li>
<li>3</li>
</ul>
<script type="text/javascript">
var type = {
THEME_UPDATE: 'theme/update',
VIS_THEME_UPDATE: 'vis/theme/update'
}
var ss = {
[type.THEME_UPDATE](state) {
console.log(state)
}
}
console.log(ss)
//function
console.log(typeof ss[type.THEME_UPDATE])
</script>
</body>
</html>
作者:孟繁贵 Email:meng010387@126.com 期待共同进步!