Taro mobx sample
nanjingboy / taro-mobx-sample Goto Github PK
View Code? Open in Web Editor NEWtaro mobx sample
taro mobx sample
请问下不支持dev:h5吗?
D:\leo\works\taro-mobx-sample>npm run dev:h5
[email protected] dev:h5 D:\leo\works\taro-mobx-sample
npm run build:h5 -- --watch[email protected] build:h5 D:\leo\works\taro-mobx-sample
taro build --type h5 "--watch"👽 Taro v1.2.7
开始编译项目 taro-mobx-sample
创建 发现文件 src\app.js
创建 发现文件 src\app.scss
创建 发现文件 src\index.html
创建 发现文件 src\store\counter.js
创建 发现文件 src\pages\index\index.js
创建 发现文件 src\pages\index\index.scssℹ️ Listening at http://127.0.0.1:10086/
监听文件修改中...
🙅 Failed to compile.
./node_modules/@tarojs/mobx-h5/index.js
Module not found: Can't resolve './Provider' in 'D:\leo\works\taro-mobx-sample\node_modules@tarojs\mobx-h5'
求大佬联系方式,讨论mobx在快应用端运行问题与方案
是否有mobx的调试工具 类似Devtools
import { observable, action } from 'mobx'
import { createContext } from '@tarojs/taro';
// 这种写法无法使用
// class MenuStore {
// isShowSeedBarn = false
// toggleIsShowSeedBarn () {
// this.isShowSeedBarn = !this.isShowSeedBarn
// }
// }
// decorate(MenuStore, {
// isShowSeedBarn: observable
// })
// 这种写法无法使用
// const MenuStore = observable({
// isShowSeedBarn: false,
// toggleIsShowSeedBarn () {
// this.isShowSeedBarn = !this.isShowSeedBarn
// }
// })
// export default createContext(MenuStore)
interface MenuStore {
isShowSeedBarn: boolean
}
class MenuStore {
@observable isShowSeedBarn = false
@action.bound
toggleIsShowSeedBarn() {
this.isShowSeedBarn = !this.isShowSeedBarn
}
}
export default createContext(new MenuStore())
上面总共有三种写法,第一种和第二种无法使用,
环境如下:
$ taro info
👽 Taro v1.3.20
Taro CLI 1.3.20 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.16.3 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
Yarn: 1.19.1 - ~\scoop\apps\nvm\current\nodejs\nodejs\yarn.CMD
npm: 6.9.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
第一种写法借鉴了 https://codesandbox.io/s/3kmkj56qm?from-embed
第二种是原来脚手架的写法
第三种是这个仓库的写法,可用.
第一种和第二种错误提示为
thirdScriptError
Cannot read property 'isShowSeedBarn' of undefined; [Component] Event Handler Error @ components/menu#(anonymous)
TypeError: Cannot read property 'isShowSeedBarn' of undefined
不知道什么原因,请求帮助(●'◡'●)
"@tarojs/mobx": "^1.1.0-beta.14",
"@tarojs/mobx-h5": "^1.1.0-beta.14",
"@tarojs/mobx-rn": "^1.1.0-beta.14",
比如
function CollectDownloadTab(props) {
const {counter} = props.counterStore
return (
<View className='row bottom-bar'>
</View>
)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.