web vue 已经发布

此版本更新内容包括:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Vue.js"></script>
</head>
<body>
    <div id="app">
        <textarea name="" id="" cols="30" rows="10"v-model.trim="msg" placeholder="请输入内容"></textarea>
        <button @click="public">发表评论</button>
        <h2>评论内容</h2>
        <ul v-if="lists.length">
            <li v-for="(list,index) in lists" :key="index">
                {{list.text}}
                <span @click="add(index)">点赞:{{list.num}}</span>
                <span style="color: red;" @click="remove(index)">删除</span>
        </li></ul>
        <p v-else>暂无评论</p>
    </div>
    <script>
        new Vue({
            el:'#app',
            data:{
                lists:[],
                msg:''
            },
            methods:{
                public(){
                    if(this.msg.length){
                        this.lists.push({
                            dog:this.msg,
                            num:0
                        })
                        this.msg=''
                    }else{
                        alert('请输入内容')
                    }
                },
                remove(i){
                    this.lists.splice(i,1)
                },
                add(i){
                    this.lists[i].num++
                }
            }
        })
    </script>
</body>
</html>

详情查看:https://gitee.com/nicia/web/releases/vue

返回顶部
顶部