(编辑:jimmy 日期: 2025/11/6 浏览:2)
概述
import Vuex from 'vuex'
const store = new Vuex.Store({ ...options })
类型: Object
Vuex store 实例的根 state 对象
类型: { [type: string]: Function }
在 store 上注册 mutation,处理函数总是接受 state 作为第一个参数(如果定义在模块中,则为模块的局部状态),payload 作为第二个参数(可选)
类型: { [type: string]: Function }
在 store 上注册 action。处理函数接受一个 context 对象,包含以下属性:
{
state, // 等同于 store.state, 若在模块中则为局部状态
rootState, // 等同于 store.state, 只存在于模块中
commit, // 等同于 store.commit
dispatch, // 等同于 store.dispatch
getters // 等同于 store.getters
}
类型: { [key: string]: Function }
在 store 上注册 getter,getter 方法接受以下参数:
"htmlcode">
{
key: {
state,
namespaced"htmlcode">
commit(type: string, payload"htmlcode">
dispatch(type: string, payload"htmlcode">
replaceState(state: Object)
替换 store 的根状态,仅用状态合并或时光旅行调试
watch(getter: Function, cb: Function, options"htmlcode">
subscribe(handler: Function)
注册监听 store 的 mutation。handler 会在每个 mutation 完成后调用,接收 mutation 和经过 mutation 后的状态作为参数
store.subscribe((mutation, state) => {
console.log(mutation.type)
console.log(mutation.payload)
})
通常用于插件
registerModule(path: string | Array<string>, module: Module)
注册一个动态模块
unregisterModule(path: string | Array<string>)
卸载一个动态模块
hotUpdate(newOptions: Object)
热替换新的 action 和 mutation
辅助函数
mapState(namespace"htmlcode">
mapGetters(namespace"htmlcode">
mapActions(namespace"htmlcode">
mapMutations(namespace"htmlcode">
createNamespacedHelpers(namespace: string): Object
更多关于VUEX方面的相关知识请点击下面的相关链接
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。