Giter VIP home page Giter VIP logo

taro-mobx-sample's Introduction

taro-mobx-sample

Taro mobx sample

taro-mobx-sample's People

Contributors

nanjingboy avatar dependabot[bot] avatar

Stargazers

AlysaLee avatar June Lau avatar izzy avatar zhaopx avatar  avatar 蟹老板 avatar TR avatar ssiapp avatar Quan avatar  avatar  avatar  avatar Jasper avatar Lila Johnson avatar JimmyLv_吕立青 avatar 饭食钢 avatar  avatar gallop avatar  avatar  avatar Kuma Li avatar  avatar  avatar  avatar TonyGee avatar Jack Lee avatar chao li avatar Mr、z avatar wind avatar Thomas Quan avatar Cuity avatar peckbyte avatar  avatar FangLiang avatar 大梦 avatar jiangbo avatar  avatar  avatar Kolf avatar  avatar Jonny Yao avatar 书越 avatar Tangqy avatar 辛宝Otto avatar linmowang avatar seaton avatar Zachary avatar ZhiHang Li avatar Rookie5 avatar

Watchers

 avatar

taro-mobx-sample's Issues

请问下不支持dev:h5吗?编译报错

请问下不支持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'

store的书写方式的问题

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

不知道什么原因,请求帮助(●'◡'●)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.