首页 > 其他 > 详细

vue添加,删除内容

时间:2018-10-23 15:33:48      阅读:184      评论:0      收藏:0      [点我收藏+]

vue 提交添加内容,点击删除内容

1 html

<input v-model="inputValue" />
    <button @click="handClick">提交</button>
    <ul>
        <todo-item 
        v-for="(item,index) in list" :key="index"
        :content="item"
        :index=‘index‘
        @delete="handdelete"
        ></todo-item>
    </ul>

2 js 

export default {
        data(){
            return{
                inputValue:‘‘,
                list:[]
            }
        },
        methods:{
        //点击提交添加内容 handClick(){
this.list.push(this.inputValue) this.inputValue=‘‘ }, // @delete="handdelete" 监听子组件的方法 delete handdelete(index){ //接收子组件传过来的index 进行删除 this.list.splice(index,1) } } }

 

vue添加,删除内容

原文:https://www.cnblogs.com/lidonglin/p/9836812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!