javascript - vue循环问题
PHPz
PHPz 2017-05-18 11:01:29
0
1
560

vue能循环一个固定变量嘛?
比如说我num=3
我要循环num次

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

<meta charset="UTF-8">
<title>Document</title>
<script src="https://unpkg.com/vue@2.3.3"></script>
</head><body>

<p id="app">
    <p v-for="n in full"></p>
    <p v-if="ishalf"></p>
    <p v-for="n in empty"></p>
</p>
<script>
    const MAXSIZE = 5;
    var vm = new Vue({
        el : '#app',
        props: {
            score:{
                type: Number,
                defualt: 4.5
            }
        },
        data:{
            num : 3
        },
        created(){
            this.full = Math.floor(this.score);
            this.ishalf = this.score!=this.full;
            this.empty = Math.floor(MAXSIZE-this.score);
        }
    })
</script>
</body></html>


PHPz
PHPz

学习是最好的投资!

全部回复(1)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!