五.品牌管理案例
本文最后更新于 1511 天前,其中的信息可能已经有所发展或是发生改变。

image

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>品牌管理</title>
    <script src="../lib/vue-2.4.0.js"></script>
</head>
<body>
    <div id="app">
            <label >Id:<input type="text" v-model="inputId"></label>
            <label >Name:<input type="text" v-model="inputName"></label>
            <input type="button" @click="create" value="增加">
            <label >搜索名字关键字:<input type="text" v-model="keyWord"></label>
            <table border="1px" style="width: 100%">
            <tr>
                <th>Id</th>
                <th>Name</th>
                <th>CreateTime</th>
                <th>Operation</th>
            </tr>
            <tr v-for="item in search(keyWord)" :key="item.id" >
                <td v-text="item.id"></td>
                <td v-text="item.name"></td>
                <td v-text="item.createTime"></td>
                <td><a @click.prevent=delate(item.id) href="">删除</a></td>
            </tr>
        </table>

    </div>
    <script>
        var vm=new Vue({
            el:"#app",
            data:{
                inputId:"",
                inputName:"",
                keyWord:"",
                list:[{id:"401",name:"奔驰",createTime:new Date()},
                    {id:"402",name:"宝马",createTime:new Date()},
                    {id:"403",name:"奔奔",createTime:new Date()},
                ],
            },
            methods:{
                delate(id){
                    console.log("delate"+id)
                    // this.list.some((item,i)=>{
                    //     if(item.id==id){
                    //         this.list.splice(i,1)
                    //         return true
                    //     }
                    // })
                    var index=this.list.findIndex((item)=>{
                        if(item.id==id){
                            return true
                        }
                    })
                    this.list.splice(index,1)
                },
                create(){
                    console.log("create");
                    this.list.push({id:this.inputId,name:this.inputName,createTime:new Date()})
                    this.inputId=this.inputName=""
                },
                search(keyWord){
                    // var newList=[];
                    // this.list.forEach(element => {
                    //     if(element.name.indexOf(keyWord)!=-1){
                    //         newList.push(element)
                    //     }
                    // });
                    // return newList
                    return this.list.filter(item=>{
                        if(item.name.includes(keyWord)){
                            return item
                        }
                    })
                }
            }
        })
    </script>
</body>
</html>
作者:Yuyy
博客:https://yuyy.info
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇