码迷,mamicode.com
首页 > 其他好文 > 详细

530 vue 一个基础语法的汇总范例 (简易留言板)

时间:2018-05-31 02:50:50      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:spl   one   click   doctype   red   ext   列表   button   height   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>简易留言板</title>
 <script  src="vue.js"></script>
<style type="text/css">
  .act{color:red;
       background-color:yellow;}
  #zuj div{
    display:none;
    width:130px;
    height:100px;
    background-color:#5E5353;
    color:#EAE8E8;
  }
 #zuj  div.show{
    display:block;
  }
  .fz{font-size:36px;}
</style>
</head>
<body>
<div id="zuj" >
   请输入你的用户名:<input type="text" v-model=‘usernm‘ ><br>
   请输入留言:<textarea v-model=‘msg‘></textarea>
   <button @click="tj">提交</button>
 留言列表
<UL>
   <li v-for="(itm,idx) in arr">
     <p>{{itm.ur}}说:</p><p>{{itm.mg}}<button @click=‘delit(idx)‘>删除</button></p></li>
</UL>
</div>
</body>
<script  type =‘text/javascript‘>
   var vm = new Vue({
      el:‘#zuj‘,
      data:{
        usernm:null,
        msg:null,
        arr:[],
      },
      methods:{
        tj(){
           var tjobj={
            ur:this.usernm,
            mg:this.msg,
            }
            this.arr.push(tjobj);
        },
        delit(index){
          this.arr.splice(index,1)
        },
      }
   })
</script>
</html>

530 vue 一个基础语法的汇总范例 (简易留言板)

标签:spl   one   click   doctype   red   ext   列表   button   height   

原文地址:https://www.cnblogs.com/xfym888/p/9114207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!