使用v-for循环输出一个九九乘法表

338 阅读1分钟

99 乘法表.png

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for指令</title>
</head>

<style>
    span {
        width: 100px;
        height: 30px;
        display: inline-block;
    }
</style>

<body>
    <div id="app">
        <div v-for="row in val">
            <span v-for="collapse in row">{{ collapse }}*{{row}}={{row*collapse}}</span>
        </div>
    </div>

    <script src="../js/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                val: 9

            }
        })
    </script>
</body>
</html>