Vue.js

<!DOCTYPE>
<html>
<head>
    <title>VUE</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>{{message}}</div>
        <span v-bind:title="message2">鼠标悬停几秒钟查看此处动态绑定的提示信息!</span>
        <button v-on:click="btnClick">反转消息</button>
        <p v-if="seen">现在你看到我了</p>
        <ol>
            <li v-for="todo in todos">{{todo.text}}</li>
        </ol>
        <ol>
            <todo-item v-for="item in todos" v-bind:todo="item" v-bind:key="item.id"></todo-item>
        </ol>
        <input v-model="message" />
    </div>
    <script type="text/javascript">
        Vue.component('todo-item', {
            props:['todo'],
            template: '<li>这是个待办事项:{{todo.text}}</li>'
        })
        var app = new Vue({
            el: "#app",
            data: {
                message: "Hello World",
                message2: '页面加载于 ' + new Date().toLocaleString(),
                seen: false,
                todos: [{ text: '学习JavaScript' }, { text: 'VUE' }, {text:'.NET'}]
            },
            methods: {
                btnClick: function () {
                    this.message = this.message.split('').reverse().join('')
                }
            }
        });
    </script>
</body>
</html>
posted @ 2021-02-02 09:35  李华丽  阅读(33)  评论(0编辑  收藏  举报
AmazingCounters.com