• Vue笔记2


    <!DOCTYPE html>
    <html>
    
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script src="vue.js" type="text/javascript" charset="UTF-8"></script>
        </head>
    
        <body>
            <div id="app">
                <div id="example-1">
                    <button v-on:click="counter+=1">数值:{{ counter }}</button><br/>
                    <button v-on:click="green('victor',$event)">执行函数</button>
                    <button v-on:dblclick="green('victor',$event)">执行函数</button>
                    
                </div>
                {{message}}
                <div class="test" v-bind:class="{active:isActive,green:isGreen}" style="200px;height:200px,text-align:center;line-height:200px;">hi vue</div>
    
                <div v-bind:class="['active','test']">HI VUE1</div>
                <div :style="{color:color,fontSize:size}">HI VUE2</div>
    
                <div v-if="type === 'A'">
                    A
                </div>
                <div v-else-if="type === 'B'">
                    B
                </div>
                <div v-else-if="type === 'C'">
                    C
                </div>
                <div v-else>
                    Not A/B/C
                </div>
    
                <h1 v-show="ok">Hello!</h1>
    
                <ul id="example-1">
                    <li v-for="item in items" v-bind:key="item.id">
                        {{ item.message }}
                    </li>
                </ul>
    
                <ul id="v-for-object" class="demo">
                    <li v-for="value in object">
                        {{ value }}
                    </li>
                </ul>
            </div>
    
            <script type="text/javascript">
                var data = {
                    counter:0,
                    message: 'Hello Vue!',
                    isActive: true,
                    isGreen: true,
                    color: 'green',
                    size: '50px',
                    type: 'B',
                    ok: true,
                    items: [{
                            message: 'Foo'
                        },
                        {
                            message: 'Bar'
                        }
                    ],
                    object: {
                        title: 'How to do lists in Vue',
                        author: 'Jane Doe',
                        publishedAt: '2016-04-10'
                    }
                }
                var app = new Vue({
                    el: '#app',
                    data: data,
                    methods:{
                        green:function(str,e){
                            console.log(e);
                            alert('hi '+str);
                            alert(this.type);
                        }
                    },
                })
            </script>
            <style>
                .test {
                    font-size: 30px;
                }
                
                .active {
                    background: #FF0000;
                }
            </style>
        </body>
    
    </html>
  • 相关阅读:
    tensorflow模型的保存与恢复
    Anaconda Linux端环境管理
    Windows环境下Redis集群部署
    Error fetching https://ruby.taobao.org/:RubySass淘宝镜源无效解决
    ORM 轻量级框架 Dapper(介绍)
    TypeScript 数据类型
    TypeScript 环境搭建
    微信小程序反编译
    利用Fiddler实现手机抓包
    SQL 优化常用查询
  • 原文地址:https://www.cnblogs.com/zhuawang/p/11540476.html
Copyright © 2020-2023  润新知