• 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("");

           }

        }

    })

     

     

     

     

  • 相关阅读:
    Less:优雅的写CSS代码
    线程池(ThreadPool)
    TiDB
    Docker实现CentOS容器SSH远程登录
    Oracle-Hints详解
    Oracle sql执行计划解析
    引擎基本服务接口API介绍
    ssh远程连接docker中linux(ubuntu/centos)
    自制操作系统
    kafka-net
  • 原文地址:https://www.cnblogs.com/chenjie00/p/7766792.html
Copyright © 2020-2023  润新知