wx-reactive
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

wx-reactive

安装

npm i wx-reactive

使用

1、新建一个store.js

import { createStore } from "wx-reactive";


// 数据
export const store = createStore({
   token: "",
});

2、app.js 引入这个文件(路径根据实际来) import "./store"

3、页面调用

import { pageReactive } from "wx-reactive";
// 引入自己创建的store(路径根据实际来)
import { store } from "../../store/index";

Page(reactive({
   data: {
      token: "",
   },
   onChangeName() {
      store.token = "tokenNewValue";
   },
}));

4、组件调用(同上) pageReactive换成componentReactive

持久缓存示例

const token = wx.getStorageSync("token");

// 数据 export const store = createStore( { token, }, (prop, value) => { if (prop === "token") { wx.setStorageSync("token", value); } } );

Readme

Keywords

none

Package Sidebar

Install

npm i wx-reactive

Weekly Downloads

1

Version

1.2.0

License

ISC

Unpacked Size

35.3 kB

Total Files

39

Last publish

Collaborators

  • huzedong2021