在父组件import引入 子组件 <collapseOption ref="collapse" ></collapseOption> <tipsDialog :show="isShow" :msg="msg" ></tipsDialog> methods: { handle() { const oneI = localStorage.getItem('oneI') const twoE = localStorage.getItem('twoE') this.$refs.collapse.selected(oneI, twoE, 1) } } 子组件一 <div @click="selected(index,num,val.other)">子组件1</div> selected(i, e, other) { localStorage.setItem('oneI', i) localStorage.setItem('twoE', e) } 子组件二 【调用子组件一的方法】 cancel() { this.$parent.handle()//调用子组件1的方法 this.$emit('show') }<van-field v-model="valOtherName[index]" ref="field" @input="getInput" @focus="getFocus" placeholder="請輸入餐廳名稱" />
========================================================
for循环渲染多个输入框input,输入时会全部的input都输入或清除,v-model使用数组的形式
标签:vue,const,oneI,twoE,调用,localStorage,组件 From: https://www.cnblogs.com/chenshaoxiong/p/16828479.html