打赏

对象属性定义方法

<!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>

 

posted @ 2018-05-25 18:33  孟繁贵  阅读(337)  评论(0编辑  收藏  举报
TOP