0
我成功地在服务器上使用Vue 2和Vuex,我有一个在挂载()函数中工作的存储。使用Vue 2 SSR和Vuex,我如何更新数据客户端?
但是,当我希望用户能够更新事物时,商店未定义,因为它不在客户端上。我该如何改变这一点?
在我当前的场景中,我使用vuex商店来保存“搜索”文本,我用它来显示基于搜索文本的项目网格。这适用于服务器端,但只要我希望用户能够键入搜索框来更改它,它就不起作用。
这就是我想做的事:
<template>
<input type="search" class="search" :value="$store.state.search" @input="changeSearch">
</template>
<script>
export default {
name: 'search-bar',
methods: {
changeSearch: (event) => this.$store.commit('SET_SEARCH', event.target.value)
}
}
</script>