初识Vue

进行了一些简单样式的渲染,主要是想了解前端如何渲染数据

<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="./observer.js"></script>
</head>
<body>


<!--        1.不能通过索引的方式去修改数组,这样不会渲染 -->
<!--        2.不能通过更改长度的方式去修改数组,这样不会渲染-->
<!--        3.数组变异方法:pop,shift,unshift,splice,sort,reverse,push-->

<!--        更改对象-->
<!--        1.向对象内添加或者删除属性,不会渲染页面-->
<!--        2. vm.$set-->



<!--    key number/string类型-->
    <div id="app">
<!--        <h4 v-for="(value,key,index) in obj">{{  key }}  -&#45;&#45;&#45;&#45;{{ value  }} &#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45; {{ index }}</h4>-->
<!--        <p v-for="item in 10">{{ item }}</p>-->
<!--        <div v-for="item in 'xiaobaibai'">{{ item  }}</div>-->
<!--        <ul>-->
<!--            <li v-for="fruit in fruitArr" :key="fruit">{{ fruit }}</li>-->
<!--        </ul>-->

<!--        <button @click="handleClick">click</button>-->

<!--        <li>香蕉</li>     香蕉-->
<!--        <li>苹果</li>     苹果-->
<!--        <li>大鸭梨</li>     大鸭梨-->
<!--        <div v-if="show">-->
<!--            name:<input type="text" key="name">-->
<!--        </div>-->
<!--        <div v-else>-->
<!--            password : <input type="text" key="password">-->
<!--        </div>-->
<!--        <button @click="handleClick">click</button>-->
<!--        <ul>-->
<!--            <li v-for="item in arr">{{ item }}</li>-->
<!--        </ul>-->
<!--        {{  obj  }}-->
<!--        <button @click="handleClick">click</button>-->
    </div>

<script>
    const index = 90;
    const fn = (item ,index) => {
        console.log(index);
    }
    fn('a' , 80);

    const vm = new Vue({
        el:'#app',

        data: {
            show: true,
            arr: ['html', 'js','vue'],
            obj:{
                name: 'shanshan',
                age: 18,
                looks: 'beautiful'
            },
            fruitArr: ['香蕉','苹果','大鸭梨'],
            index : 90
        },
        methods: {
            handleClick(){
                // this.fruitArr.reverse();
                // this.show = !this.show;
                // const length = this.arr.length;
                // this.arr[length] = 'react';
                // this.arr.push('react');
                // this.obj.name= 'xiaobai';
                // this.obj.salary=1000000000;
                // delete  this.obj.name;
                this.$set(this.obj,'salary',10000000);

            }
        }
    })
    setTimeout(() =>{
        vm.fruitArr.reverse();
    },2000)
</script>
</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值