您好,欢迎来到尔游网。
搜索
您的当前位置:首页zustand计算属性方法

zustand计算属性方法

来源:尔游网
 immer((set, get) => {
   return {
     apple: 1,
     orange: 2,
     total: () => {
       return get().apple + get().orange;
     }
  }}
  const { apple, orange, total } = useStore(
    useShallow(state => {
      return {
        apple: state.apple,
        orange: state.orange,
        total: state.total,
      };
    }),
  );
  
  const appleAdd = () => {
    useInquiryOrderEditStore.setState({
      apple: apple + 1,
    });
  };
  
<div>
   app: {apple}, orange: {orange}, total: {total()}
 </div>
 <div>
   <button onClick={appleAdd}>新增</button>
 </div>

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务