vue使用

问题一

在使用<router-link>和<router-view>时,想在子组件中使用父/兄弟组件中的数据。

我在main.js中设置:

import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({

state: {

point:0

},

mutations: {

chargePoint(state,xx){

state.point = xx

}

}

});

在父/兄弟组件中使用:

this.$store.commit("chargePoint",1);

用来设置point的值。

在子组件中使用:

this.$store.state.point可以获取它的值


问题二

<div v-for=“datas in dataAll”>

<div v-for="data in datas">{{data.name}}</div>

</div>

使用索引值改变dataAll数据可以重新渲染

在dataAll中新加数据,v-for渲染页面没有改变

我使用this.$forceUpdate();方法

強制更新当前組件


问题三

使用@click等相关时,想要获取触发事件的DOM。

test(event){

$(event.target).data("address");

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值