vue基础案例2 - 内在编辑器

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <style>
        [v-cloak]{
            display: none;
        }
        body{
            font: 15px/1.3 'Open Sans',sans-serif;
            color: #5e5b64;
            text-align: center;
        }
        a,a:visited{
            outline: none;
            color: #389dc1;
        }
        a:hover{
            text-decoration: none;
        }
        section,footer,header,aside,nav{
            display: block;
        }

        /* The edit tooltip */
        .tooltip{
            /*background-color: #5c9bb7;*/
            background-image:-webkit-linear-gradient(top,#5c9bb7,#5392ad);
            background-image:-moz-linear-gradient(top,#5c9bb7,#5392ad);
            background-image:linear-gradient(top,#5c9bb7,#5392ad);

            box-shadow: 0 1px 1px #ccc;
            border-radius: 3px;
            width: 290px;
            padding: 10px;

            position: absolute;
            left: 50%;
            margin-left: -150px;
            top: 80px;
        }

        .tooltip:after{
            /* The tip of the tooltip */
            content: '';
            position: absolute;
            border: 6px solid #5190ac;
            border-color: #5190ac transparent transparent;
            width: 0;
            height: 0;
            bottom: -12px;
            left: 50%;
            margin-left: -6px;
        }

        .tooltip > input{
            border: none;
            wdith:100%;
            line-height: 34px;
            border-radius: 3px;
            box-shadow:0 2px 6px #bbb inset;
            text-align: center;
            font-size: 16px;
            font-family: inherit;
            color: #8d9395;
            font-weight: bold;
            outline: none;
        }

        p{
            font-size: 22px;
            font-weight: bold;
            color: #6d8088;
            height: 30px;
            cursor: default;
        }

        p b{
            color: #fff;
            display: inline-block;
            padding: 5px 10px;
            background-color: #c4d7e0;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 18px;
        }

        p:before{
            content: '✎';
            display: inline-block;
            margin-right: 5px;
            font-weight: normal;
            vertical-align: text-bottom;
        }

        #main{
            border: 1px solid #ccc;
            height: 300px;
            position: relative;
            padding-top: 150px;
        }
    </style>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
   <!-- v-cloak指令可以隐藏未编译的标签直到实例准备完毕就就显示该标签 -->
    <div id="main" v-cloak v-on:click="hideTooltip">
        <div class="tooltip" v-on:click.stop v-if="show_tooltip">   <!-- stop阻止事件冒泡 -->
            <input type="text" v-model="text_content" />
        </div>

        <p v-on:click.stop="toogleTooltip">{{text_content}}</p>
    </div>



   <script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>

   <script>

        var demo = new Vue({
            el:'#main',
            data:{
                show_tooltip:false,
                text_content:'Edit me.'
            },
            methods:{
                hideTooltip:function(){
                    this.show_tooltip = false;
                },
                toogleTooltip:function(){
                    this.show_tooltip = !this.show_tooltip;
                }
            }
        });


   </script>

  </body>
</html>

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值