@labmai.dev/labmai-model
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

使用

  • npm i vite-plugin-react-model
  • main.js 放在根目录下
  • main.js 需要引入 , 代码如下
import ReactDOM from 'react-dom/client'
import App from "./src/index"
import { Provider } from '@labmai-model'

ReactDOM.createRoot(document.getElementById('root')!).render(
    <Provider>
      <App />
    </Provider>
)
  • 在src目录下创建 app.js ,并抛出 getInitialState 方法,此方法为异步,执行此方法完成以后才会进行render,代码如下
const sleep = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve(1)
        }, 5000)
    })
}
export const getInitialState = async () => {
    await sleep()
    return {
        c: 1
    }
}
  • 在src目录下创建models文件夹,后续与umi useModel一致
  • 在tsconfig中继承 src/.plugin-model/tsconfig.json

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.80latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @labmai.dev/labmai-model

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

12 kB

Total Files

8

Last publish

Collaborators

  • zhenzhong123123312
  • hanxiao.zhao
  • hongjie.zhu