vue.js-Day01

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .red{
            color: red;
        }
        .border{
            border: 1px solid #cc6600;
        }
    </style>
</head>
<body>
<div id="app">
    <p>{{msg1}}</p>
    <div v-text="msg2"></div>
    <div v-html="msg2"></div>
    <p v-show="isShow">显示和隐藏</p>
    <p v-if="isShow">添加和删除</p>
    <p v-else="true">else的添加</p>
    <input type="text" v-model="msg1">
    <p>用户输入的数据:{{msg1}}</p>
    <input type="checkbox" v-model="isTrue">

    <div :class="red">绑定一个样式</div>
    <div :class="['red','border']">绑定多个样式</div>

    <button @click="f2('hello')">点击</button>

    <p :class="{red:isShow}">{{msg3}}</p>
    <button @click="f3">点击</button>

    <ul>
        <li v-for="(item,index) in arr">{{index+1}}.{{item.name}}--{{item.age}}--{{item.sex}}</li>
    </ul>


</div>
</body>
</html>
<script src="lib/vue-2.4.0.js"></script>
<script>
/*解构赋值*/
    var user = {
        name:'张三',
        age:19
    };
    var {name,age} = user;
    console.log(name,age);
/*模板字符串*/
    var str = `大家好,我叫${user.name},今年${user.age}岁了`;
    console.log(str);
/*函数的拓展*/
    function str1(x = 10, y = 20) {
        console.log(x,y);
    }
    str1(100);
    function str2({
        x=10,
        y=20
                  }) {
        console.log(x, y);
    }
    str2({y:50});

    function arr(x,y,...args) {
        console.log(x,y,args);
    }
    arr(1,2,3,4,5,6);
/*箭头函数*/
let add = (x,y) =>{
    return x+y;
}
console.log(add(1, 2));

let add2 = x =>{
    return x;
}
console.log(add2(10));

let add3 = (x,y) => x+y;
console.log(add3(10, 30));

function f1() {
    setTimeout(() =>{
        console.log(this);
    })
}
var per = new f1();


/*Vue*/
    new Vue({
        el: '#app',
        data: {
            msg1:'hello world!',
            msg2:'<h1>hello world!</h1>',
            isShow:true,
            isTrue:true,
            msg3:'我是有颜色的',
            arr:[
                {name:'小明',age:18,sex:'男'},
                {name:'小红',age:18,sex:'女'},
                {name:'小黑',age:18,sex:'男'},
                {name:'小白',age:18,sex:'男'}
            ]
        },
        methods: {
            f2:function (h) {
                alert(h);
            },
            f3(){
                this.isShow = !this.isShow;
            }
        }
    })



</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值