zoukankan      html  css  js  c++  java
  • Vue命令(一)

    Vue Command Summary

    1.v-bind:元素节点的title属性和message保持一致。

    <div id="app-1">

        <span v-bind:title="message">

           鼠标悬停几秒来查看绑定的提示信息!

        </span>

    </div>

    var app1 = new Vue({

        el:"#app-1",

        data: {

           message:new Date().toLocaleString()

        }

    })

    app1.message = "显示"; //修改message

    2.v-if:条件命令

    <div id="app-2">

        <p v-if="seen">

           看不见我

        </p>

    </div>

    var app2 = new Vue({

        el:"#app-2",

        data: {

           seen:true

        }

    })

    app2.seen = false;

    3.v-for:循环命令

    <div id="app-3">

        <ol>

           <li v-for = "todo in todos">{{todo.text}}</li>

        </ol>

    </div>

    var app3 = new Vue({

        el:"#app-3",

        data: {

           todos:[

               {text:"第一个"},

               {text:"第二个"},

               {text:"第三个"},

               {text:"第四个"}

           ]

        }

    })

    app3.todos = [

        {text:"first"},

        {text:"second"},

        {text:"third"},

        {text:"fourth"}

    ];

    app3.todos.push({text:"fifth"});

    4.v-on:绑定事件监听

    <div id="app-4">

        <p>{{message}}</p>

        <button v-on:click="reverseMessage()">翻转</button>

    </div>

    var app4 = new Vue({

        el:"#app-4",

        data:{

           message:"Hello vue.js!",

        },

        methods:{

           reverseMessage() {

               this.message = this.message.split("").reverse().join("");

           }

        }

    })

     

     

     

     

  • 相关阅读:
    COGS 577 蝗灾 线段树+CDQ分治
    BZOJ 1305 二分+网络流
    BZOJ 1066 Dinic
    BZOJ 3544 treap (set)
    BZOJ 3940 AC自动机
    BZOJ 1503 treap
    BZOJ 3172 AC自动机
    BZOJ 2553 AC自动机+矩阵快速幂 (神题)
    BZOJ1901 ZOJ2112 线段树+treap (线段树套线段树)
    BZOJ 3196 线段树套平衡树
  • 原文地址:https://www.cnblogs.com/chenjie00/p/7766792.html
Copyright © 2011-2022 走看看