
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
npm install ymcore
//或
yarn add ymcore
//引入依赖
import React from 'react'
import API from '../../utils/axios'
import { model, useModel } from 'ymcore/useModel'
//声明model对象,指定声明空间为Demo
model({
API,
namespace: 'Demo',
kk2n: 1,
getList: 'get /biz/auth/detail/staff',
})
//使用方法
export default function Demo() {
let m = useModel('Demo')
return (
<div>
同步数据:{m.kk2n}
<br />
异步数据:{m.getListRes?.data?.staffRealName}
<br />
<button onClick={ () => m.kk2nUp(2) }>
同步数据更新
</button>
<br />
<button onClick={() => m.getList({ kk: 'ss' }) } >
异步数据更新
</button>
</div>
)
}
【Model】声明model对象,
【usemodel】,使用model对象
该函数的入参params说明:为对象object,如:
{
namespace: 'Demo',
API,
kk2n: 1,
getList: 'get /biz/auth/detail/staff',
reset(){
this.kk2n=1
}
}
【namespace】:命名空间
【API】:请求方法,如axios,fetch等等
【kk2n】:值为字符时,为状态的初始值,声明后,该model对象(称为:m),即可出现 m.kk2n状态和更新状态的方法 m.kk2nUp(newValue),入参为新值。
【getList】:值为"get post"开头的字符时,为异步请求方法,例如:"get /db/api","post /db/api",声明后,即可出现m.getList({id:1})方法,参数为请求方法的入参。并且,携带上请求结果:m.getListRes,结果有三个值:data,code,msg对应着接口返回值。
【reset】:值为函数时,为model的方法,可以在方法改变其他状态。
【第1点】:update:如果同时需要更新多个状态,你可使用
m.update({
kk2n:11,
kk3n:22
})
【第2点】:Model的状态和方法支持跨模块调用,你可以把它视为全局的store。
例如:
//自己的model
let m = useMdel('BPageDemo')
//其他模块的model
let mDemo = useMdel('Demo')
//这样,你就能在B页面使用Demo页面的状态和调用方法了
<a onClick={ () => mDemo.kk2nUp(2) }> { mDemo.kk2n } </a>
掌握以上,你就掌握全部... 从此,开始,新的快乐生活吧...
FAQs
``` npm install ymcore //或 yarn add ymcore ```
We found that ymcore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.