vue中的数据、事件、和方法

vue的特点:
1,面向数据开发,并非面向dom开发了

t-text:文本原样输出,如果要输出的文本中包含有html标签的花话,会连带html标签页一起输出到页面上
t-html:如果要输出的文本中包含有html标签的话,会自动转换成html标签
tips: 1,new Vue({})对象的时候,Vue的V大写

   <!-- vue实例的挂载点 -->
    <div id="hello">
        <h1>{{msg}}</h1>
        <h1 v-text = "ht"></h1>
        <h1 v-html = "ht"></h1>
    </div>
    <script>
        new Vue({//vue 实例中的名称可以随便自定义
            el: "#hello",//绑定id,el为挂载点
           //  template: "<h1>{{msg}}</h1>",//vue实力内部写
            data:{
                msg : "你好呀",
                num : 18,
                ht : "<h1> 我是带有html的标签文本</h1>"

            }
        })

运行结果:
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>事件、方法</title>
        <!--此引用放在head里面,而不放在body里面可以有效防止页面抖动-->
        <script src = "vue.min.js"></script>
    </head>
    <body>
        <div id = "test">
            <div v-on:click="()=>{alert('箭头函数弹窗测试')}" >{{textCon}}</div><!--箭头函数-->
            <div v-on:click="handleClick" >{{textCon1}}</div><!--箭头函数-->
            <div @click="handleClick" >{{textCon2}}</div><!--箭头函数-->
        </div>
        <script>
            new Vue({
                el: "#test",
                data: {
                    textCon : "事件测试",
                    textCon1 : "弹窗测试",
                    textCon2 : "弹窗测试"
                },
                methods:{
                    handleClick: function (){
                        this.textCon1 = "函数弹窗测试"
                    }
                }
            })
        </script>
    </body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值