zoukankan      html  css  js  c++  java
  • vue添加,删除内容

    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) } } }
  • 相关阅读:
    电源
    SM2947
    网表
    cadence设计思路
    青山依旧在,几度夕阳红
    乐观锁与悲观锁
    笔记
    强弱软虚引用
    缓存相关
    dubbo
  • 原文地址:https://www.cnblogs.com/lidonglin/p/9836812.html
Copyright © 2011-2022 走看看