Slog17_支配vue框架模版语法之v-for

2018-08-29  本文已影响9人  ArthurSlog_
关注微信公众号“ArthurSlog”

实际上 结果是最重要的 根本没有人在乎你的过程 甚至根本就没有人在乎你


开发环境MacOS(High Sierra 10.13.5)

需要的信息和信息源:

  1. v-text

  2. v-html

  3. v-show

  4. v-if

  5. v-else

  6. v-else-if

  7. v-for

  8. v-on

  9. v-bind

  10. v-model

  11. v-pre

  12. v-cload

  13. v-once

开始编码

cd ~/Desktop

mkdir node_vue_directive_learningload

cd node_vue_directive_learningload

npm init

sudo npm install koa koa-static

index.js

const serve = require('koa-static');
const Koa = require('koa');
const app = new Koa();

// $ GET /package.json
app.use(serve('.'));

app.listen(3000);

console.log('listening on port 3000');

index.html

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>ArthurSlog</title>
</head>

<body>

    <h1>The static web server by ArthurSlog</h1>

</body>

</html>

v-for.html

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <!-- 开发环境版本,包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>ArthurSlog</title>
    </head>
    <body>
        <div id="app">
            <div v-for="item in items">
            {{ item.text }}
            </div>
        </div>
        <script>
        new Vue({
            el: '#app',
            data: {
                items: [
                    {id: 0, text: 'Hello ArthurSlog~ id: 0' + '\n'},
                    {id: 1, text: 'Hello ArthurSlog~ id: 1' + '\n'},
                    {id: 2, text: 'Hello ArthurSlog~ id: 2' + '\n'}
                ]
            }
        })
        </script>
    </body>
</html>
Hello ArthurSlog~ id: 0
Hello ArthurSlog~ id: 1
Hello ArthurSlog~ id: 2
items: [
    {id: 0, text: 'Hello ArthurSlog~ id: 0' + '\n'},
    {id: 1, text: 'Hello ArthurSlog~ id: 1' + '\n'},
    {id: 2, text: 'Hello ArthurSlog~ id: 2' + '\n'}
]
<div v-for="item in items">
{{ item.text }}
</div>

欢迎关注我的微信公众号 ArthurSlog

关注微信公众号“ArthurSlog”

如果你喜欢我的文章 欢迎点赞 留言

谢谢

上一篇下一篇

猜你喜欢

热点阅读