Js学习笔记(一):vue.js初体验

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue.try</title>
</head>
<body>
    <div id = "app">
        {{ message }}
    </div>
    <div id = "app-2">
        <span v-bind:title = "message">
            鼠标悬停
        </span>
    </div>
    <div id = "app-3">
        <p v-if="seen">现在看到我了</p>
    </div>
    <div id = "app-4">
        <ol>
            <li v-for="todo in todos">
                {{ todo.text}}
            </li>
        </ol>
    </div>
    <div id = "app-5">
        <p>{{ message }}</p>
        <button v-on:click = "reverseMessage">逆转信息</button>
    </div>
    <div id = "app-6">
        <p>{{ message }}</p>
        <input v-model="message">
    </div>
    <div id = "app-7">
        <ol>
            <todo-item
                v-for = "item in groceryList" 
                v-bind:todo = "item" 
                v-bind:key = "item.id">
            </todo-item>
        </ol>
    </div>
</body>



<script src="onevue.js"></script>
</html>
<script>
    var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
})
    var app2 = new Vue({
        el : '#app-2',
        data : {
            message:'页面加载于' + new Date().toLocaleDateString()
        }
    })
    var app3 = new Vue({
        el : '#app-3',
        data:{
            seen:true
        }
    })
    var app4 = new Vue({
        el : "#app-4",
        data : {
            todos : [
                {text: '学习1'},
                {text: '学习2'},
                {text: '学习3'}
            ]
        }
    })
    var app5 = new Vue({
        el : '#app-5',
        data:{
            message:'hello Vue.js'
        },
        methods:{
            reverseMessage:function(){
                this.message = this.message.split('').reverse().join('')
            }
        }
    })
    var app6 = new Vue({
        el : '#app-6',
        data:{
            message:'Hello Vue!'
        }
    })
    Vue.component('todo-item',{
        props:['todo'],
        template:'<li>{{ todo.text }}</li>'
    })
    var app7 = new Vue({
        el : '#app-7',
        data:{
            groceryList:[
                {id:0,text:'蔬菜'},
                {id:1,text:'奶酪'},
                {id:2,text:'随便其他什么人吃的东西'}
            ]
        }
    })
</script>

前端页面效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
</head>
<body>
    <div id="app">
        <pre><a v-bind:href="url">页面跳转</a></pre>
    </div>
    <div id="app1">
        {{ message | capitalize }}
    </div>
</body>
<script src="onevue.js"></script>
<script>
    new Vue({
        el:'#app',
        data:{
            url:"https://blog.csdn.net/xiaohuoche175"
        }
    })
</script>
<script>
    new Vue({
        el:"#app1",
        data:{
            message: 'runoob'
        },
        filters: {
            capitalize: function (value) {
                if (!value) return ''
                value = value.toString()
                return value.charAt(0).toUpperCase() + value.slice(1)
            }
        }
    })
</script>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值