1
私はこれを置く方法を知らないが、私は2つの異なる場所で使用するコンポーネントを持っており、このコンポーネントには<input v-model="model" >
があります。 私のコンポーネントでこのvモデルを見ています。 問題はモデルが変更されていることです。ある場所で私はmodel = array.val1を持っていて、2番目に私はmodel = array.val2を持っています と私はmodel = array.val1のときに何かしたいと思います、そしてモデル= array.val2のときに別のことをしたいです 私はそれが等しい何かが、これはこの同じコンポーネントで異なるv-modelを見る方法はありますか?
を行うならばモデルに条件を行いたい、これはだから私は、私はコンポーネントを再利用し、これまでときたいが、そのモデルに同じことを行ういけない私のコンポーネント
Vue.component('boisson-view', {
props: ["boiss", "model","type","name"],
template: `
<div class="radio">
<label>
<input :type="type" :name="name" v-model="model" :value="boiss.id" >
{{boiss.name}}
<img :src="boiss.link" :id="boiss.id" style="display:none;position: fixed;">
</label>
</div>`,
created:function(){
this.setboisson = vm.setboisson;
},
watch: {
'model': { handler : function(val) {
// this will get triggered within boisson-view component, when one of your "o" changes
if(val !== null)
this.ord.is_menu = true;
else
this.ord.is_menu = false;
console.log(JSON.stringify(val));
},deep:true
},
}
ある
おそらく、同じものを再利用する代わりに2つのコンポーネントを使用します – brahimm